Module: SteelWheel::Composition::InstanceMethods
- Defined in:
- lib/steel_wheel/composition.rb
Overview
rubocop:disable Style/Documentation
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
22 23 24 25 26 27 28 29 |
# File 'lib/steel_wheel/composition.rb', line 22 def method_missing(name, *attrs, **kwargs, &block) return super unless name.to_s.start_with?('owner_') owner_method = name.to_s.sub('owner_', '').to_sym return super unless (handler = owners_chain.detect { |o| o.respond_to?(owner_method) }) handler.public_send(owner_method, *attrs, **kwargs, &block) end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
31 32 33 34 35 |
# File 'lib/steel_wheel/composition.rb', line 31 def respond_to_missing?(method_name, include_private = false) return super unless method_name.to_s.start_with?('owner_') owners_chain.any? { |o| o.respond_to?(method_name.to_s.sub('owner_', '').to_sym, include_private) } end |