Class: Decorator
- Inherits:
-
Object
- Object
- Decorator
- Defined in:
- lib/decorator.rb
Overview
Base decorator class
Instance Attribute Summary collapse
-
#decorated_class ⇒ Symbol
readonly
The method being decorated.
-
#decorated_method ⇒ Symbol
readonly
The method being decorated.
Instance Method Summary collapse
-
#call_next(this, chain, *args) ⇒ Object
The hook to call chained decorations.
-
#initialize(decorated_class, decorated_method) ⇒ Decorator
constructor
private
Decorator constructor interface.
Constructor Details
#initialize(decorated_class, decorated_method) ⇒ Decorator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Decorator constructor interface
39 40 41 42 |
# File 'lib/decorator.rb', line 39 def initialize(decorated_class, decorated_method) @decorated_class = decorated_class @decorated_method = decorated_method end |
Instance Attribute Details
#decorated_class ⇒ Symbol (readonly)
The method being decorated
16 17 18 |
# File 'lib/decorator.rb', line 16 def decorated_class @decorated_class end |
#decorated_method ⇒ Symbol (readonly)
The method being decorated
28 29 30 |
# File 'lib/decorator.rb', line 28 def decorated_method @decorated_method end |
Instance Method Details
#call_next(this, chain, *args) ⇒ Object
The hook to call chained decorations
62 63 64 65 66 67 68 69 70 |
# File 'lib/decorator.rb', line 62 def call_next(this, chain, *args) next_caller = chain.shift if next_caller.nil? decorated_method.bind(this).call(*args) else next_caller.call(this, chain, *args) end end |