Class: PostgresPR::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/ap4r/message_store_ext.rb

Instance Method Summary collapse

Instance Method Details

#original_queryObject



491
# File 'lib/ap4r/message_store_ext.rb', line 491

alias original_query query

#query(q, &block) ⇒ Object



493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/ap4r/message_store_ext.rb', line 493

def query(q, &block)
  # In PostgresPR, +query+ method does NOT care about a given block.
  # To deal with a given block, this method adds iteration
  # over query results.
  maybe_result = original_query(q, &block)
  puts "PostgresPR: query called by #{q}" if $DEBUG
  puts "PostgresPR::Connenction#query returns #{maybe_result}(class: #{maybe_result.class})." if $DEBUG
  return maybe_result unless block && maybe_result.kind_of?(PostgresPR::Connection::Result)
  begin
    puts "PostgresPR extention: about to yield result." if $DEBUG
    block.call(maybe_result.rows)
  ensure
    maybe_result = nil
  end
end

#quote(str) ⇒ Object



509
510
511
512
# File 'lib/ap4r/message_store_ext.rb', line 509

def quote(str)
  # do nothing
  str
end