Class: PG::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/db/pg.rb

Overview

PG patches, keep in mind exec and async_exec have a exec{|r| } semantics that is yet to be implemented

Instance Method Summary collapse

Instance Method Details

#each(*args, &blk) ⇒ Object



15
16
17
18
19
20
# File 'lib/patches/db/pg.rb', line 15

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

#each_without_profilingObject



5
# File 'lib/patches/db/pg.rb', line 5

alias_method :each_without_profiling, :each

#mp_report_sql(&block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/patches/db/pg.rb', line 22

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



8
9
10
11
12
13
# File 'lib/patches/db/pg.rb', line 8

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

#values_without_profilingObject



6
# File 'lib/patches/db/pg.rb', line 6

alias_method :values_without_profiling, :values