Class: Aquarium::Aspects::NoAdviceChainNode

Inherits:
AdviceChainNode show all
Defined in:
lib/aquarium/aspects/advice.rb

Overview

When invoking the original method, we use object.send(original_method_name, *args) rather than object.method(…).call(*args). The latter fails when the original method calls super. This is a Ruby bug: www.ruby-forum.com/topic/124276

Constant Summary

Constants inherited from AdviceChainNode

AdviceChainNode::NIL_OBJECT

Instance Method Summary collapse

Methods inherited from AdviceChainNode

#call, #call_advice, #each, #empty?, #invoke_original_join_point, #last, #size

Constructor Details

#initialize(options = {}) ⇒ NoAdviceChainNode

Note that we extract the block passed to the original method call, if any, from the context and pass it to method invocation.



159
160
161
# File 'lib/aquarium/aspects/advice.rb', line 159

def initialize options = {}
  super options
end

Instance Method Details

#advice_wrapper(jp) ⇒ Object



162
163
164
# File 'lib/aquarium/aspects/advice.rb', line 162

def advice_wrapper jp
  jp.context.advised_object.send @alias_method_name, *jp.context.parameters, &jp.context.block_for_method
end