Module: EasyParams::Composition::InstanceMethods
- Defined in:
- lib/easy_params/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
20 21 22 23 24 25 26 27 |
# File 'lib/easy_params/composition.rb', line 20 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.lazy.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
29 30 31 32 33 |
# File 'lib/easy_params/composition.rb', line 29 def respond_to_missing?(method_name, include_private = false) return super unless method_name.to_s.start_with?('owner_') owners_chain.lazy.any? { |o| o.respond_to?(method_name.to_s.sub('owner_', '').to_sym, include_private) } end |