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



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/action_widget/view_helper.rb', line 3

def method_missing(name, *args, &block)
  widget = ActionWidget[name]
  return super if widget.nil?

  ActionWidget::ViewHelper.module_eval "    def \#{name}(*args, &block)                          # def example_widget(*args, &block)\n      attrs = args.last.kind_of?(Hash) ? args.pop : {}\n      \#{widget}.new(self, attrs).render(*args, &block)  #   ExampleWidget.new(self, attrs).render(*args, &block)\n    end                                                 # end\n  RUBY\n\n  send(name, *args, &block)\nend\n"

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/action_widget/view_helper.rb', line 17

def respond_to_missing?(name, include_private = false)
  !!ActionWidget[name] || super
end