Class Aquarium::Aspects::JoinPoint::Context
In: lib/aquarium/aspects/join_point.rb
Parent: Object

JoinPoint::Context

Encapsulates current runtime context information for a join point, such as the values of method parameters, a raised exception (for :after or after_raising advice), etc. Context objects are partly value objects. TODO Separate out the read-only part from the variable part. This might require an API change!

Methods

<=>   ==   ===   eql?   invoke_original_join_point   new   proceed   update  

Constants

NIL_OBJECT = Aquarium::Utils::NilObject.new

External Aliases

advised_object -> target_object
inspect -> to_s

Attributes

advice_kind  [RW] 
advised_object  [RW] 
block_for_method  [RW] 
current_advice_node  [RW] 
parameters  [RW] 
proceed_proc  [RW] 
raised_exception  [RW] 
returned_value  [RW] 

Public Class methods

[Source]

    # File lib/aquarium/aspects/join_point.rb, line 32
32:         def initialize options = {}
33:           update options
34:         end

Public Instance methods

We require the same object id, not just equal objects.

[Source]

    # File lib/aquarium/aspects/join_point.rb, line 62
62:         def <=> other
63:           return 0 if object_id == other.object_id 
64:           return 1 if other.nil?
65:           result = self.class <=> other.class 
66:           return result unless result == 0
67:           result = Advice.compare_advice_kinds self.advice_kind, other.advice_kind
68:           return result unless result == 0
69:           result = (self.advised_object.object_id.nil? and other.advised_object.object_id.nil?) ? 0 : self.advised_object.object_id <=> other.advised_object.object_id 
70:           return result unless result == 0
71:           result = (self.parameters.nil? and other.parameters.nil?) ? 0 : self.parameters <=> other.parameters 
72:           return result unless result == 0
73:           result = (self.returned_value.nil? and other.returned_value.nil?) ? 0 : self.returned_value <=> other.returned_value 
74:           return result unless result == 0
75:           (self.raised_exception.nil? and other.raised_exception.nil?) ? 0 : self.raised_exception <=> other.raised_exception
76:         end
==(other)

Alias for eql?

===(other)

Alias for eql?

[Source]

    # File lib/aquarium/aspects/join_point.rb, line 78
78:         def eql? other
79:           (self <=> other) == 0
80:         end

[Source]

    # File lib/aquarium/aspects/join_point.rb, line 52
52:         def invoke_original_join_point enclosing_join_point, *args, &block
53:           raise ContextNotCorrectlyDefined.new("It looks like you tried to call \"JoinPoint#invoke_original_join_point\" (or \"JoinPoint::Context#invoke_original_join_point\") using a join point without a completely formed context object. (Specific error: The original join point cannot be invoked because no \"@current_advice_node\" attribute was set on the corresponding JoinPoint::Context object.)") if @current_advice_node.nil?
54:           enclosing_join_point.context.parameters = args unless args.nil? or args.empty? 
55:           enclosing_join_point.context.block_for_method = block if block 
56:           current_advice_node.invoke_original_join_point enclosing_join_point
57:         end

[Source]

    # File lib/aquarium/aspects/join_point.rb, line 45
45:         def proceed enclosing_join_point, *args, &block
46:           raise ProceedMethodNotAvailable.new("It looks like you tried to call \"JoinPoint#proceed\" (or \"JoinPoint::Context#proceed\") from within advice that isn't \"around\" advice. Only around advice can call proceed. (Specific error: JoinPoint#proceed cannot be invoked because no \"@proceed_proc\" attribute was set on the corresponding JoinPoint::Context object.)") if @proceed_proc.nil?
47:           enclosing_join_point.context.parameters = args unless args.nil? or args.empty? 
48:           enclosing_join_point.context.block_for_method = block if block 
49:           proceed_proc.call enclosing_join_point
50:         end

[Source]

    # File lib/aquarium/aspects/join_point.rb, line 36
36:         def update options
37:           options.each do |key, value|
38:             instance_variable_set "@#{key}", value
39:           end
40:           @advice_kind    ||= Advice::UNKNOWN_ADVICE_KIND
41:           @advised_object ||= NIL_OBJECT
42:           @parameters     ||= []
43:         end

[Validate]