Module: Draper::AutomaticDelegation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/draper/automatic_delegation.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#method_missing(method, *args, &block) ⇒ Object
Delegates missing instance methods to the source object.
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Checks if the decorator responds to an instance method, or is able to proxy it to the source object.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Delegates missing instance methods to the source object.
6 7 8 9 10 11 |
# File 'lib/draper/automatic_delegation.rb', line 6 def method_missing(method, *args, &block) return super unless delegatable?(method) self.class.delegate method send(method, *args, &block) end |
Instance Method Details
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Checks if the decorator responds to an instance method, or is able to proxy it to the source object.
15 16 17 |
# File 'lib/draper/automatic_delegation.rb', line 15 def respond_to_missing?(method, include_private = false) super || delegatable?(method) end |