Class: MetaDb::PostgresResult

Inherits:
Result
  • Object
show all
Defined in:
lib/meta_db/connection.rb

Instance Method Summary collapse

Methods inherited from Result

#initialize

Constructor Details

This class inherits a constructor from MetaDb::Result

Instance Method Details

#each_array(&block) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/meta_db/connection.rb', line 64

def each_array(&block)
  if block_given?
    each_array.each(&block)
  else
    @result.each_row
  end
end

#each_hash(&block) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/meta_db/connection.rb', line 56

def each_hash(&block) 
  if block_given?
    each_hash.each(&block)
  else
    @result.map { |row| row.map { |field, value| [field.to_sym, value] }.to_h }
  end
end

#sizeObject



52
53
54
# File 'lib/meta_db/connection.rb', line 52

def size()
  @result.ntuples
end

#to_aObject



72
# File 'lib/meta_db/connection.rb', line 72

def to_a() @result.values end