class AlgebraDB::Build::SelectList::RowDecoder

Row decoder that delegates to the decoders of the items in the select list.

Attributes

column_decoders[R]

Public Class Methods

new(columns) click to toggle source
# File lib/algebra_db/build/select_list.rb, line 26
def initialize(columns) # rubocop:disable Lint/MissingSuper
  @columns = columns
  @column_decoders = columns.map(&:decoder)
end

Public Instance Methods

decode_row(row) click to toggle source
# File lib/algebra_db/build/select_list.rb, line 37
def decode_row(row)
  values = row.values.map.with_index do |r, i|
    @column_decoders[i].decode_value(r)
  end
  row_struct.new(*values)
end
pg_type_map() click to toggle source
# File lib/algebra_db/build/select_list.rb, line 33
def pg_type_map
  PG::TypeMapByColumn.new(column_decoders.map(&:pg_decoder))
end
row_struct() click to toggle source
# File lib/algebra_db/build/select_list.rb, line 44
def row_struct
  @row_struct ||= Struct.new(*@columns.map { |c| c.select_alias.to_sym })
end