module FactoryBotInstruments::Tracing

Public Instance Methods

trace(sql: true) { || ... } click to toggle source
# File lib/factory_bot_instruments/tracing.rb, line 66
def trace(sql: true)
  result = nil

  begin
    $FACTORY_BOT_INSTRUMENTS_TRACING = true
    $FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH = 0

    FactoryBotInstruments::TracingHelpers.sql_tracer(sql) do
      result = yield
    end
  ensure
    $FACTORY_BOT_INSTRUMENTS_TRACING = false
    $FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH = 0
  end

  result
end