Class: Pgoutput::Decoder::RowBuilder
- Inherits:
-
Object
- Object
- Pgoutput::Decoder::RowBuilder
- Defined in:
- lib/pgoutput/decoder/row_builder.rb
Overview
Builds decoded row hashes from Relation metadata and TupleValue arrays.
Instance Method Summary collapse
-
#build(relation, tuple) ⇒ Hash<String, Object>
Build a decoded row hash.
- #initialize(type_registry: TypeRegistry.default) ⇒ void constructor
Constructor Details
#initialize(type_registry: TypeRegistry.default) ⇒ void
11 12 13 14 |
# File 'lib/pgoutput/decoder/row_builder.rb', line 11 def initialize(type_registry: TypeRegistry.default) @value_decoder = ValueDecoder.new(type_registry: type_registry) freeze end |
Instance Method Details
#build(relation, tuple) ⇒ Hash<String, Object>
Build a decoded row hash.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pgoutput/decoder/row_builder.rb', line 21 def build(relation, tuple) row = {} tuple.each_with_index do |tuple_value, index| column = relation.columns[index] next unless column normalized_value = normalize_oid(tuple_value, column.oid) row[column.name] = @value_decoder.decode(normalized_value) end Ractor.make_shareable(row.freeze) end |