Class: SourceRoute::TpResult

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/source_route/tp_result.rb

Overview

delegate to hash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ TpResult



9
10
11
# File 'lib/source_route/tp_result.rb', line 9

def initialize(data)
  @core = data
end

Instance Attribute Details

#coreObject

Returns the value of attribute core.



4
5
6
# File 'lib/source_route/tp_result.rb', line 4

def core
  @core
end

Instance Method Details

#==(other) ⇒ Object



21
22
23
24
# File 'lib/source_route/tp_result.rb', line 21

def ==(other)
  @core[:tp_self] == other[:tp_self] and @core[:method_id] == other[:method_id] and
    @core[:defined_class] == other[:defined_class]
end

#call_event?Boolean



17
18
19
# File 'lib/source_route/tp_result.rb', line 17

def call_event?
  @core[:event] == :call
end

#matched?Boolean



26
27
28
# File 'lib/source_route/tp_result.rb', line 26

def matched?
  @core[:matched]
end

#return_assign_call(tp) ⇒ Object



30
31
32
33
34
35
# File 'lib/source_route/tp_result.rb', line 30

def return_assign_call(tp)
  @core[:matched] = true
  tp[:return_value] = @core[:return_value]
  tp[:local_var] = @core[:local_var] if has_key? :local_var
  tp[:instance_var] = @core[:instance_var] if has_key? :instance_var
end

#return_event?Boolean



13
14
15
# File 'lib/source_route/tp_result.rb', line 13

def return_event?
  @core[:event] == :return
end

#stringifyObject



37
38
39
40
41
42
43
44
# File 'lib/source_route/tp_result.rb', line 37

def stringify
  dup_core = @core.dup
  # to_s is safer than inspect
  # ex: inspect on ActiveRecord_Relation may crash
  dup_core[:defined_class] = dup_core[:defined_class].to_s if dup_core.has_key?(:defined_class)
  dup_core[:return_value] = dup_core[:return_value].source_route_display if dup_core.has_key?(:return_value)
  dup_core
end