Class: SCNR::Introspector::ExecutionFlow
- Inherits:
-
Object
- Object
- SCNR::Introspector::ExecutionFlow
- Defined in:
- lib/scnr/introspector/execution_flow.rb,
lib/scnr/introspector/execution_flow/point.rb,
lib/scnr/introspector/execution_flow/scope.rb
Defined Under Namespace
Instance Attribute Summary collapse
- #points ⇒ Array<Point> readonly
- #scope ⇒ Scope
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ ExecutionFlow
constructor
A new instance of ExecutionFlow.
- #to_rpc_data ⇒ Object
- #trace(&block) ⇒ ExecutionFlow
Constructor Details
#initialize(options = {}, &block) ⇒ ExecutionFlow
Returns a new instance of ExecutionFlow.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/scnr/introspector/execution_flow.rb', line 25 def initialize( = {}, &block ) = .dup if (scope = .delete(:scope)).is_a? ExecutionFlow::Scope @scope = scope elsif scope.is_a? Hash @scope = ExecutionFlow::Scope.new( scope ) elsif scope.nil? @scope = ExecutionFlow::Scope.new else fail ExecutionFlow::Scope::Error::Invalid end @points = [] trace( &block ) if block_given? end |
Instance Attribute Details
#points ⇒ Array<Point> (readonly)
13 14 15 |
# File 'lib/scnr/introspector/execution_flow.rb', line 13 def points @points end |
#scope ⇒ Scope
10 11 12 |
# File 'lib/scnr/introspector/execution_flow.rb', line 10 def scope @scope end |
Class Method Details
.from_rpc_data(h) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/scnr/introspector/execution_flow.rb', line 80 def self.from_rpc_data( h ) n = self.new h.each do |k, v| case k when 'points' n.instance_variable_set( "@#{k}", v.map { |pd| Point.from_rpc_data( pd ) } ) else n.instance_variable_set( "@#{k}", v ) end end n end |
Instance Method Details
#to_rpc_data ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/scnr/introspector/execution_flow.rb', line 60 def to_rpc_data data = {} instance_variables.each do |iv| case iv when :@points data['points'] = @points.map(&:to_rpc_data) when :@scope next else v = instance_variable_get( iv ) next if !v data[iv.to_s.gsub('@','')] = v.to_rpc_data end end data end |
#trace(&block) ⇒ ExecutionFlow
50 51 52 53 54 55 56 57 58 |
# File 'lib/scnr/introspector/execution_flow.rb', line 50 def trace( &block ) TracePoint.new do |tp| next if @scope.out?( tp.path ) @points << create_point_from_trace_point( tp ) end.enable(&block) self end |