Class: Manufacturable::Dispatcher
- Inherits:
-
Object
- Object
- Manufacturable::Dispatcher
- Defined in:
- lib/manufacturable/dispatcher.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Instance Method Summary collapse
-
#initialize(message:, receiver:) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #method_missing(name, *args, **kwargs) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(message:, receiver:) ⇒ Dispatcher
Returns a new instance of Dispatcher.
5 6 7 8 |
# File 'lib/manufacturable/dispatcher.rb', line 5 def initialize(message:, receiver:) @message = @receiver = receiver end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs) ⇒ Object
10 11 12 13 14 |
# File 'lib/manufacturable/dispatcher.rb', line 10 def method_missing(name, *args, **kwargs) return super unless respond_to?(name) Manufacturable.build_one(receiver, name, *args, **kwargs).public_send() end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/manufacturable/dispatcher.rb', line 3 def @message end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
3 4 5 |
# File 'lib/manufacturable/dispatcher.rb', line 3 def receiver @receiver end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
16 17 18 |
# File 'lib/manufacturable/dispatcher.rb', line 16 def respond_to_missing?(name, include_private = false) Manufacturable.builds?(receiver, name) || super end |