Declares helper accessors for controller attributes. For example, the following adds new name and name= instance methods to a controller and makes them available to the view:
helper_attr :name attr_accessor :name
| *attrs | Names of attributes to be converted |
into helpers.
# File lib/action_controller/metal/helpers.rb, line 80
80: def helper_attr(*attrs)
81: attrs.flatten.each { |attr| helper_method(attr, "#{attr}=") }
82: end
Provides a proxy to access helpers methods from outside the view.
# File lib/action_controller/metal/helpers.rb, line 85
85: def helpers
86: @helper_proxy ||= ActionView::Base.new.extend(_helpers)
87: end
Extract helper names from files in app/helpers/**/*_helper.rb
# File lib/action_controller/metal/helpers.rb, line 105
105: def all_application_helpers
106: helpers = []
107: Array.wrap(helpers_path).each do |path|
108: extract = /^#{Regexp.quote(path.to_s)}\/?(.*)_helper.rb$/
109: helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
110: end
111: helpers.sort!
112: helpers.uniq!
113: helpers
114: end
Overwrite modules_for_helpers to accept :all as argument, which loads all helpers in helpers_dir.
| args | A list of helpers |
| Array[Module] | A normalized list of modules for the list of |
helpers provided.
# File lib/action_controller/metal/helpers.rb, line 99
99: def modules_for_helpers(args)
100: args += all_application_helpers if args.delete(:all)
101: super(args)
102: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.