Class: GunDog::CallRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/gun_dog/call_record.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, method_name, class_method: false) ⇒ CallRecord

Returns a new instance of CallRecord.



24
25
26
27
28
# File 'lib/gun_dog/call_record.rb', line 24

def initialize(klass, method_name, class_method: false)
  @klass = klass
  @method_name = method_name
  @class_method = class_method
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/gun_dog/call_record.rb', line 3

def args
  @args
end

#cyclical=(value) ⇒ Object (writeonly)

Sets the attribute cyclical

Parameters:

  • value

    the value to set the attribute cyclical to.



6
7
8
# File 'lib/gun_dog/call_record.rb', line 6

def cyclical=(value)
  @cyclical = value
end

#internal=(value) ⇒ Object (writeonly)

Sets the attribute internal

Parameters:

  • value

    the value to set the attribute internal to.



6
7
8
# File 'lib/gun_dog/call_record.rb', line 6

def internal=(value)
  @internal = value
end

#method_nameObject

Returns the value of attribute method_name.



3
4
5
# File 'lib/gun_dog/call_record.rb', line 3

def method_name
  @method_name
end

#return_valueObject

Returns the value of attribute return_value.



3
4
5
# File 'lib/gun_dog/call_record.rb', line 3

def return_value
  @return_value
end

#stackObject

Returns the value of attribute stack.



4
5
6
# File 'lib/gun_dog/call_record.rb', line 4

def stack
  @stack
end

Class Method Details

.from_json(json) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gun_dog/call_record.rb', line 8

def self.from_json(json)
  cr = new(const_get(json['klass']),
      json['method_name'],
      class_method: json['class_method'])

  cr.instance_eval do
    @internal = json['internal']
    @cyclical = json['cyclical']
    @args = json['args']
    @return_value = json['return_value']
    @stack = json['stack']
  end

  cr
end

Instance Method Details

#as_jsonObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/gun_dog/call_record.rb', line 50

def as_json
  {
    "klass" => @klass,
    "method_name" => method_name,
    "class_method" => class_method?,
    "internal" => internal?,
    "cyclical" => cyclical?,
    "args" => args,
    "return_value" => return_value,
    "stack" => stack
  }.reject { |_,v| v.nil? }
end

#class_method?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/gun_dog/call_record.rb', line 42

def class_method?
  !!@class_method
end

#cyclical?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/gun_dog/call_record.rb', line 38

def cyclical?
  !!@cyclical
end

#internal?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/gun_dog/call_record.rb', line 34

def internal?
  !!@internal
end

#method_locationObject



30
31
32
# File 'lib/gun_dog/call_record.rb', line 30

def method_location
  "#{@klass}#{method_separator}#{method_name}"
end

#to_sObject



46
47
48
# File 'lib/gun_dog/call_record.rb', line 46

def to_s
  "def #{method_name}(#{type_signatures(args)}) => #{return_value}"
end