Class: Decorator::Base
- Inherits:
-
Object
- Object
- Decorator::Base
- Defined in:
- lib/method_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(this, *args, &block) ⇒ Object
-
#initialize(method, *args, &block) ⇒ Base
constructor
A new instance of Base.
- #original(this, *args, &block) ⇒ Object
Constructor Details
#initialize(method, *args, &block) ⇒ Base
Returns a new instance of Base.
59 60 61 62 63 |
# File 'lib/method_decorator.rb', line 59 def initialize(method, *args, &block) @method = method @decorator_args = args @decorator_block = block end |
Class Method Details
.decorator_name(name) ⇒ Object
48 49 50 51 |
# File 'lib/method_decorator.rb', line 48 def decorator_name(name) Decorator::DecoratorAware.registry ||= {} Decorator::DecoratorAware.registry[self] = name.to_sym end |
.inherited(klass) ⇒ Object
53 54 55 56 |
# File 'lib/method_decorator.rb', line 53 def inherited(klass) Decorator::DecoratorAware.registry ||= {} Decorator::DecoratorAware.registry[klass] = klass.name.to_sym end |
Instance Method Details
#call(this, *args, &block) ⇒ Object
69 70 71 |
# File 'lib/method_decorator.rb', line 69 def call(this, *args, &block) raise NotImplementedError.new(self.class.name + '.' + __method__.to_s + ' method must be implemented') end |
#original(this, *args, &block) ⇒ Object
65 66 67 |
# File 'lib/method_decorator.rb', line 65 def original(this, *args, &block) @method.bind(this).call(*args, &block) end |