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

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

Instance Method Summary collapse

Constructor Details

#initialize(connection, result) ⇒ HashRecord

Returns a new instance of HashRecord.



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

def initialize(connection, result)
  super(connection, result)
  @field_names = result.fields.map(&:to_sym)
end

Instance Method Details

#decode(row) ⇒ Object



115
116
117
118
# File 'lib/simple/sql/helpers/decoder.rb', line 115

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