Class: RShade::Event
Overview
nodoc
Constant Summary collapse
- RETURN_EVENTS =
i[return b_return c_return].freeze
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#skipped ⇒ Object
readonly
Returns the value of attribute skipped.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Event
constructor
A new instance of Event.
- #return_value!(return_value) ⇒ Object
- #with_level!(level) ⇒ Object
- #with_serialized_return!(serializer) ⇒ Object
- #with_serialized_vars!(serializer) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Event
Returns a new instance of Event.
10 11 12 |
# File 'lib/rshade/event.rb', line 10 def initialize(hash) @hash = hash end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
6 7 8 |
# File 'lib/rshade/event.rb', line 6 def hash @hash end |
#skipped ⇒ Object (readonly)
Returns the value of attribute skipped.
6 7 8 |
# File 'lib/rshade/event.rb', line 6 def skipped @skipped end |
Class Method Details
.from_trace_point(evt) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rshade/event.rb', line 40 def self.from_trace_point(evt) vars = {} evt.binding.local_variables.each do |var_name| local_val = evt.binding.local_variable_get(var_name) local_val_type = local_val.is_a?(Class) ? local_val : local_val.class hash = { name: var_name, value: local_val, type: local_val_type } vars[var_name] = hash end hash = { path: evt.path, lineno: evt.lineno, klass: evt.defined_class, method_name: evt.method_id, vars: vars, event_type: evt.event } if RETURN_EVENTS.include?(evt.event) ret_val = evt.return_value ret_val_type = evt.return_value.is_a?(Class) ? evt.return_value : evt.return_value.class hash.merge!({ return_value: { value: ret_val, type: ret_val_type } }) end new(hash) end |
Instance Method Details
#return_value!(return_value) ⇒ Object
25 26 27 28 |
# File 'lib/rshade/event.rb', line 25 def return_value!(return_value) @hash[:return_value] = return_value self end |
#with_level!(level) ⇒ Object
20 21 22 23 |
# File 'lib/rshade/event.rb', line 20 def with_level!(level) @hash[:level] = level self end |
#with_serialized_return!(serializer) ⇒ Object
30 31 32 33 |
# File 'lib/rshade/event.rb', line 30 def with_serialized_return!(serializer) @hash[:return_value] = serializer.call(@hash[:return_value]) self end |
#with_serialized_vars!(serializer) ⇒ Object
35 36 37 38 |
# File 'lib/rshade/event.rb', line 35 def with_serialized_vars!(serializer) @hash[:vars] = serializer.call(@hash[:vars]) self end |