Class: Velocity::PostgreSQLResult::PostgreSQLMappedRow

Inherits:
MappedRow
  • Object
show all
Defined in:
lib/velocity/results/postgresql.rb

Instance Attribute Summary

Attributes inherited from MappedRow

#tuple

Instance Method Summary collapse

Methods inherited from MappedRow

#inspect

Constructor Details

#initialize(pg_query) ⇒ PostgreSQLMappedRow

Returns a new instance of PostgreSQLMappedRow.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/velocity/results/postgresql.rb', line 5

def initialize(pg_query)
  @fields = pg_query.fields
  @pg_query = pg_query
  
  # It is imperitive that the adapter return the array in the same sequence of fields provided above
  # If this isn't the case, some re-ordering of the field KEYS should take place
  @fields.each_with_index do |field, index|
    define_singleton_method(field) do
      pg_query.getvalue(@tuple, index)
    end
  end
end

Instance Method Details

#attributesObject



18
19
20
# File 'lib/velocity/results/postgresql.rb', line 18

def attributes
  @pg_query[@tuple] # Try to avoid calling this, its relatively slow.
end