Class: CheapAdvice::ActivationRecord
- Inherits:
-
Object
- Object
- CheapAdvice::ActivationRecord
- Defined in:
- lib/cheap_advice.rb
Overview
Represents the activation record of a method invocation.
Constant Summary collapse
- DELEGATE_TO_ADVISED =
This methods are delegated to #advised.
[ :advice, :mod, :meth, :kind, :meth_to_s ].freeze
Instance Attribute Summary collapse
-
#advised ⇒ Object
readonly
The Advised method binding object.
-
#args ⇒ Object
The original message receiver, arguments and block (if given).
-
#block ⇒ Object
The original message receiver, arguments and block (if given).
-
#data ⇒ Object
Arbitrary data accessed by #[], #[]=.
-
#error ⇒ Object
(also: #exception)
Any Exception rescued from the original method.
-
#rcvr ⇒ Object
The original message receiver, arguments and block (if given).
-
#result ⇒ Object
The original message return result available in the :around or :after advice blocks.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#caller(offset = 0) ⇒ Object
The call stack with CheapAdvice methods filtered out.
-
#initialize(*args) ⇒ ActivationRecord
constructor
A new instance of ActivationRecord.
Constructor Details
#initialize(*args) ⇒ ActivationRecord
Returns a new instance of ActivationRecord.
484 485 486 |
# File 'lib/cheap_advice.rb', line 484 def initialize *args @advised, @rcvr, @args, @block = *args end |
Instance Attribute Details
#advised ⇒ Object (readonly)
The Advised method binding object.
461 462 463 |
# File 'lib/cheap_advice.rb', line 461 def advised @advised end |
#args ⇒ Object
The original message receiver, arguments and block (if given). Can be modified by the advice blocks.
465 466 467 |
# File 'lib/cheap_advice.rb', line 465 def args @args end |
#block ⇒ Object
The original message receiver, arguments and block (if given). Can be modified by the advice blocks.
465 466 467 |
# File 'lib/cheap_advice.rb', line 465 def block @block end |
#data ⇒ Object
Arbitrary data accessed by #[], #[]=. Advice blocks can use this to store arbitrary data. May be a frozen, empty Hash.
482 483 484 |
# File 'lib/cheap_advice.rb', line 482 def data @data end |
#error ⇒ Object Also known as: exception
Any Exception rescued from the original method. Usually nil if no exception was raised; if not nil, Exception is reraised after the :around advice block. Can be modified by the :after advice block.
475 476 477 |
# File 'lib/cheap_advice.rb', line 475 def error @error end |
#rcvr ⇒ Object
The original message receiver, arguments and block (if given). Can be modified by the advice blocks.
465 466 467 |
# File 'lib/cheap_advice.rb', line 465 def rcvr @rcvr end |
#result ⇒ Object
The original message return result available in the :around or :after advice blocks. Value can be changed in the advice blocks to alter the return result.
469 470 471 |
# File 'lib/cheap_advice.rb', line 469 def result @result end |
Instance Method Details
#[](key) ⇒ Object
492 493 494 |
# File 'lib/cheap_advice.rb', line 492 def [] key (@data || EMPTY_Hash)[key] end |
#[]=(key, value) ⇒ Object
496 497 498 |
# File 'lib/cheap_advice.rb', line 496 def []= key, value (@data ||= { })[key] = value end |
#caller(offset = 0) ⇒ Object
The call stack with CheapAdvice methods filtered out.
505 506 507 |
# File 'lib/cheap_advice.rb', line 505 def caller(offset = 0) ::Kernel.caller(offset + 2) end |