Class: Decorate::AroundDecorator::AroundCall
- Defined in:
- lib/decorate/around_decorator.rb
Overview
An AroundCall holds the auxiliary information that is passed as argument to an around method.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Original argument list.
-
#block ⇒ Object
readonly
Original block.
-
#message ⇒ Object
readonly
The message that was sent resulting in this around call.
-
#receiver ⇒ Object
readonly
Receiving object.
-
#result ⇒ Object
readonly
Holds the result of a transfer to the wrapped method.
-
#wrapped_message ⇒ Object
readonly
The name of the method that constitutes the “core” behaviour (behaviour without the around logic).
Instance Method Summary collapse
-
#initialize(receiver, message, wrapped_message, args, block) ⇒ AroundCall
constructor
A new instance of AroundCall.
-
#transfer(args = @args, &block) ⇒ Object
Call the wrapped method.
Constructor Details
#initialize(receiver, message, wrapped_message, args, block) ⇒ AroundCall
Returns a new instance of AroundCall.
29 30 31 32 33 34 35 36 |
# File 'lib/decorate/around_decorator.rb', line 29 def initialize(receiver, , , args, block) @receiver = receiver @message = @wrapped_message = @args = args @block = block @result = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
Original argument list.
21 22 23 |
# File 'lib/decorate/around_decorator.rb', line 21 def args @args end |
#block ⇒ Object (readonly)
Original block.
24 25 26 |
# File 'lib/decorate/around_decorator.rb', line 24 def block @block end |
#message ⇒ Object (readonly)
The message that was sent resulting in this around call.
14 15 16 |
# File 'lib/decorate/around_decorator.rb', line 14 def @message end |
#receiver ⇒ Object (readonly)
Receiving object.
11 12 13 |
# File 'lib/decorate/around_decorator.rb', line 11 def receiver @receiver end |
#result ⇒ Object (readonly)
Holds the result of a transfer to the wrapped method.
27 28 29 |
# File 'lib/decorate/around_decorator.rb', line 27 def result @result end |
#wrapped_message ⇒ Object (readonly)
The name of the method that constitutes the “core” behaviour (behaviour without the around logic).
18 19 20 |
# File 'lib/decorate/around_decorator.rb', line 18 def @wrapped_message end |
Instance Method Details
#transfer(args = @args, &block) ⇒ Object
Call the wrapped method. args
and block
default to original ones passed by client code. The return value of the wrapped method is stored in the result
attribute and also returned from transfer.
42 43 44 45 |
# File 'lib/decorate/around_decorator.rb', line 42 def transfer(args = @args, &block) block ||= @block @result = @receiver.__send__(@wrapped_message, *args, &block) end |