Module: Nina::MethodMissingDelegation
- Defined in:
- lib/nina.rb
Overview
Adds ability to delegeate methods via method_missing
Instance Method Summary collapse
- #method_missing(name, *attrs, **kwargs, &block) ⇒ Object
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *attrs, **kwargs, &block) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/nina.rb', line 35 def method_missing(name, *attrs, **kwargs, &block) if (prev = predecessors.lazy.detect { |o| o.public_methods.include?(name) }) prev.public_send(name, *attrs, **kwargs, &block) else super end end |
Instance Method Details
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
43 44 45 |
# File 'lib/nina.rb', line 43 def respond_to_missing?(method_name, _include_private = false) public_methods.detect { |m| m == :predecessor } || super end |