Class: Decors::DecoratorBase

Inherits:
Object
  • Object
show all
Defined in:
lib/decors/decorator_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_classObject (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_methodObject (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_argsObject (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_blockObject (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_kwargsObject (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_methodObject (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_nameObject



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