Module: RailsViewHelperObjects::DefineHelperMethod
- Defined in:
- lib/rails-view-helper-objects/define_helper_method.rb
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rails-view-helper-objects/define_helper_method.rb', line 3 def self.included klass method_name = klass.name.underscore.split("/").last # create a view helper that returns klass.new ActionView::Helpers.module_eval do define_method method_name do |*args| obj = klass.new(*args) # give the object access to the view obj.__view__ = self obj end end end |