Module: FactoryGirlInstruments::Tracing

Included in:
FactoryGirl
Defined in:
lib/factory_girl_instruments/tracing.rb

Instance Method Summary collapse

Instance Method Details

#trace(sql: true) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/factory_girl_instruments/tracing.rb', line 66

def trace(sql: true)
  result = nil

  begin
    $FACTORY_GIRL_INSTRUMENTS_TRACING = true
    $FACTORY_GIRL_INSTRUMENTS_TRACING_DEPTH = 0

    FactoryGirlInstruments::TracingHelpers.sql_tracer(sql) do
      result = yield
    end
  ensure
    $FACTORY_GIRL_INSTRUMENTS_TRACING = false
    $FACTORY_GIRL_INSTRUMENTS_TRACING_DEPTH = 0
  end

  result
end