Module: PG::Result::MiniProfiler

Included in:
PG::Result
Defined in:
lib/patches/db/pg/prepend.rb

Instance Method Summary collapse

Instance Method Details

#each(*args, &blk) ⇒ Object



12
13
14
15
16
17
# File 'lib/patches/db/pg/prepend.rb', line 12

def each(*args, &blk)
  return super unless defined?(@miniprofiler_sql_id)
  mp_report_sql do
    super
  end
end

#mp_report_sql(&block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/patches/db/pg/prepend.rb', line 19

def mp_report_sql(&block)
  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = yield
  elapsed_time = SqlPatches.elapsed_time(start)
  @miniprofiler_sql_id.report_reader_duration(elapsed_time)
  result
end

#values(*args, &blk) ⇒ Object



5
6
7
8
9
10
# File 'lib/patches/db/pg/prepend.rb', line 5

def values(*args, &blk)
  return super unless defined?(@miniprofiler_sql_id)
  mp_report_sql do
    super
  end
end