Method: SolidCache::Record.with_instrumenter

Defined in:
app/models/solid_cache/record.rb

.with_instrumenter(instrumenter, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/solid_cache/record.rb', line 16

def with_instrumenter(instrumenter, &block)
  with_connection do |connection|
    if connection.respond_to?(:with_instrumenter)
      connection.with_instrumenter(instrumenter, &block)
    else
      begin
        old_instrumenter, ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = ActiveSupport::IsolatedExecutionState[:active_record_instrumenter], instrumenter
        block.call
      ensure
        ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = old_instrumenter
      end
    end
  end
end