Class: Simple::SQL::Helpers::Decoder::MultiColumns

Inherits:
Object
  • Object
show all
Defined in:
lib/simple/sql/helpers/decoder.rb

Direct Known Subclasses

HashRecord

Constant Summary collapse

H =
::Simple::SQL::Helpers

Instance Method Summary collapse

Constructor Details

#initialize(column_info) ⇒ MultiColumns

Returns a new instance of MultiColumns.



91
92
93
# File 'lib/simple/sql/helpers/decoder.rb', line 91

def initialize(column_info)
  @field_types = H.pluck(column_info, :pg_type_name)
end

Instance Method Details

#decode(row) ⇒ Object



95
96
97
98
99
# File 'lib/simple/sql/helpers/decoder.rb', line 95

def decode(row)
  @field_types.zip(row).map do |field_type, value|
    value && Simple::SQL::Helpers::Decoder.decode_value(field_type, value)
  end
end