Class: Decors::DecoratorBase
- Inherits:
-
Object
- Object
- Decors::DecoratorBase
- Defined in:
- lib/decors/decorator_base.rb
Instance Attribute Summary collapse
-
#decorated_class ⇒ Object
readonly
Returns the value of attribute decorated_class.
-
#decorated_method ⇒ Object
readonly
Returns the value of attribute decorated_method.
-
#decorator_args ⇒ Object
readonly
Returns the value of attribute decorator_args.
-
#decorator_block ⇒ Object
readonly
Returns the value of attribute decorator_block.
-
#decorator_kwargs ⇒ Object
readonly
Returns the value of attribute decorator_kwargs.
-
#undecorated_method ⇒ Object
readonly
Returns the value of attribute undecorated_method.
Instance Method Summary collapse
- #call(instance, *args, &block) ⇒ Object
- #decorated_method_name ⇒ Object
-
#initialize(decorated_class, undecorated_method, decorated_method, *args, **kwargs, &block) ⇒ DecoratorBase
constructor
A new instance of DecoratorBase.
- #undecorated_call(instance, *args, &block) ⇒ Object
Constructor Details
#initialize(decorated_class, undecorated_method, decorated_method, *args, **kwargs, &block) ⇒ DecoratorBase
Returns a new instance of DecoratorBase.
6 7 8 9 10 11 12 13 |
# File 'lib/decors/decorator_base.rb', line 6 def initialize(decorated_class, undecorated_method, decorated_method, *args, **kwargs, &block) @decorated_class = decorated_class @undecorated_method = undecorated_method @decorated_method = decorated_method @decorator_args = args @decorator_kwargs = kwargs @decorator_block = block end |
Instance Attribute Details
#decorated_class ⇒ Object (readonly)
Returns the value of attribute decorated_class.
3 4 5 |
# File 'lib/decors/decorator_base.rb', line 3 def decorated_class @decorated_class end |
#decorated_method ⇒ Object (readonly)
Returns the value of attribute decorated_method.
3 4 5 |
# File 'lib/decors/decorator_base.rb', line 3 def decorated_method @decorated_method end |
#decorator_args ⇒ Object (readonly)
Returns the value of attribute decorator_args.
3 4 5 |
# File 'lib/decors/decorator_base.rb', line 3 def decorator_args @decorator_args end |
#decorator_block ⇒ Object (readonly)
Returns the value of attribute decorator_block.
3 4 5 |
# File 'lib/decors/decorator_base.rb', line 3 def decorator_block @decorator_block end |
#decorator_kwargs ⇒ Object (readonly)
Returns the value of attribute decorator_kwargs.
3 4 5 |
# File 'lib/decors/decorator_base.rb', line 3 def decorator_kwargs @decorator_kwargs end |
#undecorated_method ⇒ Object (readonly)
Returns the value of attribute undecorated_method.
3 4 5 |
# File 'lib/decors/decorator_base.rb', line 3 def undecorated_method @undecorated_method end |
Instance Method Details
#call(instance, *args, &block) ⇒ Object
15 16 17 |
# File 'lib/decors/decorator_base.rb', line 15 def call(instance, *args, &block) undecorated_call(instance, *args, &block) end |
#decorated_method_name ⇒ Object
23 24 25 |
# File 'lib/decors/decorator_base.rb', line 23 def decorated_method_name decorated_method.name end |
#undecorated_call(instance, *args, &block) ⇒ Object
19 20 21 |
# File 'lib/decors/decorator_base.rb', line 19 def undecorated_call(instance, *args, &block) undecorated_method.bind(instance).call(*args, &block) end |