instance method
modules_for_helpers
Ruby on Rails 4.0.13
Since v3.0.20Signature
modules_for_helpers(args)
Returns a list of modules, normalized from the acceptable kinds of helpers with the following behavior:
- String or Symbol
-
:FooBar or “FooBar” becomes “foo_bar_helper”,
and “foo_bar_helper.rb” is loaded using require_dependency.
- Module
-
No further processing
After loading the appropriate files, the corresponding modules are returned.
Parameters
-
args- An array of helpers
Returns
-
Array- A normalized list of modules for the list of helpers provided.
Parameters
-
argsreq
Source
# File actionpack/lib/abstract_controller/helpers.rb, line 129
def modules_for_helpers(args)
args.flatten.map! do |arg|
case arg
when String, Symbol
file_name = "#{arg.to_s.underscore}_helper"
begin
require_dependency(file_name)
rescue LoadError => e
raise MissingHelperError.new(e, file_name)
end
file_name.camelize.constantize
when Module
arg
else
raise ArgumentError, "helper must be a String, Symbol, or Module"
end
end
end
Defined in actionpack/lib/abstract_controller/helpers.rb line 129
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in AbstractController::Helpers::ClassMethods