Class: Stratagem::Instrumentation::MethodInvocation
- Defined in:
- lib/stratagem/instrumentation/method_invocation.rb
Constant Summary collapse
- EQUALITY_ATTRS =
[:method, :controller_path, :controller_action, :line_number, :model_class]
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#controller_action ⇒ Object
Returns the value of attribute controller_action.
-
#controller_path ⇒ Object
Returns the value of attribute controller_path.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#method ⇒ Object
Returns the value of attribute method.
-
#model_class ⇒ Object
Returns the value of attribute model_class.
-
#model_instance ⇒ Object
Returns the value of attribute model_instance.
-
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #controller ⇒ Object
-
#eql?(other) ⇒ Boolean
override so that uniq works properly.
-
#initialize(*args) ⇒ MethodInvocation
constructor
TODO - refactor, ugly constructor is a result of quick port from Struct.
- #model ⇒ Object
- #print ⇒ Object
- #to_reference ⇒ Object
Constructor Details
#initialize(*args) ⇒ MethodInvocation
TODO - refactor, ugly constructor is a result of quick port from Struct
8 9 10 11 12 13 14 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 8 def initialize(*args) arg_keys = [:method, :controller_path, :controller_action, :line_number, :model_instance, :model_class, :stack_trace, :args, :type] args.each_with_index do |val,i| self.send("#{arg_keys[i].to_s}=", val) end self.controller_path = controller_path.gsub(/.*?\/app/, 'app') if controller_path end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def args @args end |
#controller_action ⇒ Object
Returns the value of attribute controller_action.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def controller_action @controller_action end |
#controller_path ⇒ Object
Returns the value of attribute controller_path.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def controller_path @controller_path end |
#line_number ⇒ Object
Returns the value of attribute line_number.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def line_number @line_number end |
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def method @method end |
#model_class ⇒ Object
Returns the value of attribute model_class.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def model_class @model_class end |
#model_instance ⇒ Object
Returns the value of attribute model_instance.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def model_instance @model_instance end |
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def stack_trace @stack_trace end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 3 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 19 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 16 def <=>(other) e = self.==(other) e ? 0 : 1 end |
#==(other) ⇒ Object
21 22 23 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 21 def ==(other) eql?(other) end |
#controller ⇒ Object
32 33 34 35 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 32 def controller app = Stratagem::Model::Application.instance controller = controller_path ? app.controllers.find {|controller| controller.path == controller_path } : nil end |
#eql?(other) ⇒ Boolean
override so that uniq works properly
26 27 28 29 30 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 26 def eql?(other) EQUALITY_ATTRS.find {|key| (self.send(key) != other.send(key)) }.nil? end |
#model ⇒ Object
37 38 39 40 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 37 def model app = Stratagem::Model::Application.instance model = model_class ? app.models.find {|model| model.klass.name == model_class.name } : nil end |
#print ⇒ Object
54 55 56 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 54 def print puts "#{controller_path}.#{controller_action}:#{line_number} -> #{model_class.name}.#{method}" end |
#to_reference ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/stratagem/instrumentation/method_invocation.rb', line 42 def to_reference Stratagem::Model::Component::Reference.new( :from_component => controller, :to_component => model, :function => controller_action, :request_method => method, :line_number => line_number, :reference_type => type, :stack_trace => stack_trace ) end |