Class: Manufacturable::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/manufacturable/dispatcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = 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(message)
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/manufacturable/dispatcher.rb', line 3

def message
  @message
end

#receiverObject (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

Returns:

  • (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