Class: Pgoutput::Decoder::ValueDecoder
- Inherits:
-
Object
- Object
- Pgoutput::Decoder::ValueDecoder
- Defined in:
- lib/pgoutput/decoder/value_decoder.rb
Overview
Decodes one pgoutput-parser TupleValue using a TypeRegistry.
Instance Method Summary collapse
-
#decode(tuple_value) ⇒ Object, ...
Decode one tuple value.
- #initialize(type_registry: TypeRegistry.default) ⇒ void constructor
Constructor Details
#initialize(type_registry: TypeRegistry.default) ⇒ void
11 12 13 14 |
# File 'lib/pgoutput/decoder/value_decoder.rb', line 11 def initialize(type_registry: TypeRegistry.default) @type_registry = type_registry freeze end |
Instance Method Details
#decode(tuple_value) ⇒ Object, ...
Decode one tuple value.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pgoutput/decoder/value_decoder.rb', line 20 def decode(tuple_value) case tuple_value.format when :null nil when :unchanged_toast :unchanged_toast when :text, :binary @type_registry.decode(tuple_value.oid, tuple_value.raw, tuple_value.format) else raise ValueDecodeError, "unsupported tuple value format: #{tuple_value.format.inspect}" end end |