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.



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



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