Module: ActionWidget::ViewHelper
- Defined in:
- lib/action_widget/view_helper.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/action_widget/view_helper.rb', line 4 def method_missing(name, *args, &block) return super unless name =~ /_widget$/ klass = begin "#{name.to_s.camelcase}".constantize rescue NameError, LoadError return super end ActionWidget::ViewHelper.module_eval <<-RUBY def #{name}(*args, &block) # def example_widget(*args, &block) #{klass}.new(self, *args).render(&block) # ExampleWidget.new(self, *args).render(&block) end # end RUBY send(name, *args, &block) end |