Class: Mozart::Composite
- Inherits:
-
Object
- Object
- Mozart::Composite
- Defined in:
- lib/mozart/composite.rb
Instance Method Summary collapse
- #<<(part) ⇒ Object
- #dispatch(message, *a, &b) ⇒ Object
-
#initialize ⇒ Composite
constructor
A new instance of Composite.
- #receives?(message) ⇒ Boolean
Constructor Details
#initialize ⇒ Composite
Returns a new instance of Composite.
5 6 7 |
# File 'lib/mozart/composite.rb', line 5 def initialize self.parts = [] end |
Instance Method Details
#<<(part) ⇒ Object
9 10 11 |
# File 'lib/mozart/composite.rb', line 9 def <<(part) parts << part end |
#dispatch(message, *a, &b) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mozart/composite.rb', line 17 def dispatch(, *a, &b) target = recipient() unless target raise NotImplementedError, "No recipient implements #{}" end target.public_send(, *a, &b) end |
#receives?(message) ⇒ Boolean
13 14 15 |
# File 'lib/mozart/composite.rb', line 13 def receives?() !!recipient() end |