Class: Solace::Serializers::Base

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/solace/serializers/base.rb

Direct Known Subclasses

BaseDeserializer, BaseSerializer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*args, **kwargs) ⇒ String

Proxy method to call the serializer and create a new instance

Returns:

  • (String)

    The serialized record (base64)



11
12
13
# File 'lib/solace/serializers/base.rb', line 11

def self.call(*args, **kwargs)
  new(*args, **kwargs).call
end

Instance Method Details

#callString

Serializes the record

Returns:

  • (String)

    The serialized record (base64)



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/solace/serializers/base.rb', line 18

def call
  bin = self.class::STEPS
        .map { |m| send(m) }
        .flatten
        .compact
        .pack('C*')

  Base64.strict_encode64(bin)
rescue NameError => e
  raise "STEPS must be defined: #{e.message}"
end