Class: Solace::Serializers::BaseDeserializer

Inherits:
Base
  • Object
show all
Defined in:
lib/solace/serializers/base_deserializer.rb

Overview

Base deserializer class

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(io) ⇒ BaseDeserializer

Initialize a new deserializer

Parameters:

  • io (IO or StringIO)

    The input to read bytes from.



42
43
44
45
# File 'lib/solace/serializers/base_deserializer.rb', line 42

def initialize(io)
  @io = io
  @record = self.class.record_class.new
end

Class Attribute Details

.record_classClass

Returns The class of the record.

Returns:

  • (Class)

    The class of the record



24
25
26
# File 'lib/solace/serializers/base_deserializer.rb', line 24

def record_class
  @record_class
end

.RECORD_CLASSObject

The class of the record being deserialized



24
# File 'lib/solace/serializers/base_deserializer.rb', line 24

attr_accessor :record_class

.STEPSObject

An ordered list of methods to deserialize the record



18
# File 'lib/solace/serializers/base_deserializer.rb', line 18

attr_accessor :steps

.stepsArray

Returns The steps to deserialize the record.

Returns:

  • (Array)

    The steps to deserialize the record



18
19
20
# File 'lib/solace/serializers/base_deserializer.rb', line 18

def steps
  @steps
end

Instance Attribute Details

#ioObject

The input to read bytes from.



36
37
38
# File 'lib/solace/serializers/base_deserializer.rb', line 36

def io
  @io
end

#recordIO or StringIO, Record

Returns:

  • (IO or StringIO)

    The input to read bytes from.

  • (Record)

    The deserialized record.



36
# File 'lib/solace/serializers/base_deserializer.rb', line 36

attr_reader :io, :record

Instance Method Details

#callRecord

Deserializes the record

Returns:

  • (Record)

    The deserialized record



50
51
52
53
# File 'lib/solace/serializers/base_deserializer.rb', line 50

def call
  self.class.steps.each { send(_1) }
  record
end