Class: Simple::SQL::Helpers::Decoder::HashRecord

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

Constant Summary collapse

H =
::Simple::SQL::Helpers

Instance Method Summary collapse

Constructor Details

#initialize(column_info) ⇒ HashRecord

Returns a new instance of HashRecord.



105
106
107
108
# File 'lib/simple/sql/helpers/decoder.rb', line 105

def initialize(column_info)
  super(column_info)
  @field_names = H.pluck(column_info, :name)
end

Instance Method Details

#decode(row) ⇒ Object



110
111
112
113
# File 'lib/simple/sql/helpers/decoder.rb', line 110

def decode(row)
  decoded_row = super(row)
  Hash[@field_names.zip(decoded_row)]
end