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.
# File actionpack/lib/abstract_controller/helpers.rb, line 144
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 AbstractController::Helpers::MissingHelperError.new(e, file_name)
end
mod_name = file_name.camelize
begin
mod_name.constantize
rescue LoadError
# dependencies.rb gives a similar error message but its wording is
# not as clear because it mentions autoloading. To the user all it
# matters is that a helper module couldn't be loaded, autoloading
# is an internal mechanism that should not leak.
raise NameError, "Couldn't find #{mod_name}, expected it to be defined in helpers/#{file_name}.rb"
end
when Module
arg
else
raise ArgumentError, "helper must be a String, Symbol, or Module"
end
end
end