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, **kwargs, &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, **kwargs, &block) ⇒ Object
Constructor Details
#initialize(decorated_class, undecorated_method, decorated_method, *args, **kwargs, &block) ⇒ DecoratorBase
Returns a new instance of DecoratorBase.
8 9 10 11 12 13 14 15 |
# File 'lib/decors/decorator_base.rb', line 8 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.
5 6 7 |
# File 'lib/decors/decorator_base.rb', line 5 def decorated_class @decorated_class end |
#decorated_method ⇒ Object (readonly)
Returns the value of attribute decorated_method.
5 6 7 |
# File 'lib/decors/decorator_base.rb', line 5 def decorated_method @decorated_method end |
#decorator_args ⇒ Object (readonly)
Returns the value of attribute decorator_args.
5 6 7 |
# File 'lib/decors/decorator_base.rb', line 5 def decorator_args @decorator_args end |
#decorator_block ⇒ Object (readonly)
Returns the value of attribute decorator_block.
5 6 7 |
# File 'lib/decors/decorator_base.rb', line 5 def decorator_block @decorator_block end |
#decorator_kwargs ⇒ Object (readonly)
Returns the value of attribute decorator_kwargs.
5 6 7 |
# File 'lib/decors/decorator_base.rb', line 5 def decorator_kwargs @decorator_kwargs end |
#undecorated_method ⇒ Object (readonly)
Returns the value of attribute undecorated_method.
5 6 7 |
# File 'lib/decors/decorator_base.rb', line 5 def undecorated_method @undecorated_method end |
Instance Method Details
#call(instance, *args, **kwargs, &block) ⇒ Object
17 18 19 |
# File 'lib/decors/decorator_base.rb', line 17 def call(instance, *args, **kwargs, &block) undecorated_call(instance, *args, **kwargs, &block) end |
#decorated_method_name ⇒ Object
25 26 27 |
# File 'lib/decors/decorator_base.rb', line 25 def decorated_method_name decorated_method.name end |
#undecorated_call(instance, *args, **kwargs, &block) ⇒ Object
21 22 23 |
# File 'lib/decors/decorator_base.rb', line 21 def undecorated_call(instance, *args, **kwargs, &block) undecorated_method.bind(instance).call(*args, **kwargs, &block) end |