Class: Orthoses::CallTracer::Lazy
- Inherits:
-
Object
- Object
- Orthoses::CallTracer::Lazy
- Includes:
- Capturable
- Defined in:
- lib/orthoses/call_tracer/lazy.rb
Overview
CallTracer::Lazy is possible to perform a trace equivalent to CallTracer before method is defined.
scope = CallTracerLazy.new
scope.trace("ActiveRecord::Base#scope") do
require 'active_record/all'
@loader.call
end
scope.captures.each do |capture|
capture.argument[:name]
capture.argument[:body]
capture.argument[:block]
end
Instance Attribute Summary collapse
-
#captures ⇒ Object
readonly
Returns the value of attribute captures.
Instance Method Summary collapse
-
#initialize ⇒ Lazy
constructor
A new instance of Lazy.
- #trace(name, &block) ⇒ Object
Methods included from Capturable
Constructor Details
#initialize ⇒ Lazy
Returns a new instance of Lazy.
22 23 24 25 26 27 |
# File 'lib/orthoses/call_tracer/lazy.rb', line 22 def initialize @captures = [] @lazy_trace_point = LazyTracePoint.new(:call) do |tp| @captures << build_capture(tp) end end |
Instance Attribute Details
#captures ⇒ Object (readonly)
Returns the value of attribute captures.
20 21 22 |
# File 'lib/orthoses/call_tracer/lazy.rb', line 20 def captures @captures end |
Instance Method Details
#trace(name, &block) ⇒ Object
29 30 31 |
# File 'lib/orthoses/call_tracer/lazy.rb', line 29 def trace(name, &block) @lazy_trace_point.enable(target: name, &block) end |