Class: PG::Result

Inherits:
Object
  • Object
show all
Includes:
MiniProfiler
Defined in:
lib/patches/db/pg/alias_method.rb,
lib/patches/db/pg/prepend.rb

Defined Under Namespace

Modules: MiniProfiler

Instance Method Summary collapse

Instance Method Details

#each(*args, &blk) ⇒ Object



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

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



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

alias_method :each_without_profiling, :each

#mp_report_sql(&block) ⇒ Object



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

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



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

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



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

alias_method :values_without_profiling, :values