Class: GunDog::CallRecord
- Inherits:
-
Object
- Object
- GunDog::CallRecord
- Defined in:
- lib/gun_dog/call_record.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#cyclical ⇒ Object
writeonly
Sets the attribute cyclical.
-
#dynamic ⇒ Object
writeonly
Sets the attribute dynamic.
-
#internal ⇒ Object
writeonly
Sets the attribute internal.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#return_value ⇒ Object
Returns the value of attribute return_value.
-
#stack ⇒ Object
Returns the value of attribute stack.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #call_record_signature ⇒ Object
- #class_method? ⇒ Boolean
- #cyclical? ⇒ Boolean
- #dynamic? ⇒ Boolean
- #generated? ⇒ Boolean
-
#initialize(klass, method_name, class_method: false, generated: false) ⇒ CallRecord
constructor
A new instance of CallRecord.
- #internal? ⇒ Boolean
- #method_location ⇒ Object
- #unbound_method ⇒ Object
Constructor Details
#initialize(klass, method_name, class_method: false, generated: false) ⇒ CallRecord
Returns a new instance of CallRecord.
29 30 31 32 33 34 |
# File 'lib/gun_dog/call_record.rb', line 29 def initialize(klass, method_name, class_method: false, generated: false) @klass = klass @method_name = method_name @class_method = class_method @generated = generated end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
5 6 7 |
# File 'lib/gun_dog/call_record.rb', line 5 def args @args end |
#cyclical=(value) ⇒ Object (writeonly)
Sets the attribute cyclical
8 9 10 |
# File 'lib/gun_dog/call_record.rb', line 8 def cyclical=(value) @cyclical = value end |
#dynamic=(value) ⇒ Object (writeonly)
Sets the attribute dynamic
8 9 10 |
# File 'lib/gun_dog/call_record.rb', line 8 def dynamic=(value) @dynamic = value end |
#internal=(value) ⇒ Object (writeonly)
Sets the attribute internal
8 9 10 |
# File 'lib/gun_dog/call_record.rb', line 8 def internal=(value) @internal = value end |
#method_name ⇒ Object
Returns the value of attribute method_name.
5 6 7 |
# File 'lib/gun_dog/call_record.rb', line 5 def method_name @method_name end |
#return_value ⇒ Object
Returns the value of attribute return_value.
5 6 7 |
# File 'lib/gun_dog/call_record.rb', line 5 def return_value @return_value end |
#stack ⇒ Object
Returns the value of attribute stack.
6 7 8 |
# File 'lib/gun_dog/call_record.rb', line 6 def stack @stack end |
Class Method Details
.from_json(json) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gun_dog/call_record.rb', line 10 def self.from_json(json) cr = new( Utilities.get_class(json['klass']), json['method_name'], class_method: json['class_method'], generated: json['generated'] ) cr.instance_eval do @internal = json['internal'] @cyclical = json['cyclical'] @args = json['args'] @return_value = json['return_value'] @stack = TraceStack.from_array(klass: @klass, stack: json['stack']) if json['stack'] end cr end |
Instance Method Details
#as_json ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gun_dog/call_record.rb', line 76 def as_json { "klass" => @klass.json_encoded, "method_name" => method_name.to_s, "class_method" => class_method?, "generated" => generated?, "internal" => internal?, "cyclical" => cyclical?, "dynamic" => dynamic?, "args" => args.each_pair.with_object({}) { |(k,v), memo| memo[k.to_s] = v}, "return_value" => return_value, "stack" => stack&.as_json }.reject { |_,v| v.nil? } end |
#call_record_signature ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/gun_dog/call_record.rb', line 68 def call_record_signature "#{generated? ? "[generated] " : nil } \ def #{class_method? ? "self." : nil}#{method_name}(#{type_signatures(args)}) : #{return_value.class} \ #{ internal? ? " (internal)" : nil } \ #{ cyclical? ? " (cyclical)" : nil } \ #{ dynamic? ? " (dynamic)" : nil }".squish end |
#class_method? ⇒ Boolean
52 53 54 |
# File 'lib/gun_dog/call_record.rb', line 52 def class_method? !!@class_method end |
#cyclical? ⇒ Boolean
44 45 46 |
# File 'lib/gun_dog/call_record.rb', line 44 def cyclical? !!@cyclical end |
#dynamic? ⇒ Boolean
48 49 50 |
# File 'lib/gun_dog/call_record.rb', line 48 def dynamic? !!@dynamic end |
#generated? ⇒ Boolean
56 57 58 |
# File 'lib/gun_dog/call_record.rb', line 56 def generated? !!@generated end |
#internal? ⇒ Boolean
40 41 42 |
# File 'lib/gun_dog/call_record.rb', line 40 def internal? !!@internal end |
#method_location ⇒ Object
36 37 38 |
# File 'lib/gun_dog/call_record.rb', line 36 def method_location "#{@klass}#{method_separator}#{method_name}" end |
#unbound_method ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/gun_dog/call_record.rb', line 60 def unbound_method if class_method? @klass.method(method_name).unbind else @klass.instance_method(method_name) end end |