Class: Paquito::CodecFactory::MessagePackCodec
- Inherits:
-
Object
- Object
- Paquito::CodecFactory::MessagePackCodec
- Defined in:
- lib/paquito/codec_factory.rb
Instance Method Summary collapse
- #dump(object) ⇒ Object
-
#initialize(factory, freeze: false) ⇒ MessagePackCodec
constructor
A new instance of MessagePackCodec.
- #load(payload) ⇒ Object
Constructor Details
#initialize(factory, freeze: false) ⇒ MessagePackCodec
Returns a new instance of MessagePackCodec.
27 28 29 30 |
# File 'lib/paquito/codec_factory.rb', line 27 def initialize(factory, freeze: false) @factory = factory @freeze = freeze end |
Instance Method Details
#dump(object) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/paquito/codec_factory.rb', line 32 def dump(object) @factory.dump(object) rescue NoMethodError => error raise PackError.new(error., error.receiver) rescue RangeError => error raise PackError, "#{error.class.name}, #{error.}" end |
#load(payload) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/paquito/codec_factory.rb', line 40 def load(payload) if @freeze @factory.load(payload, freeze: @freeze) else @factory.load(payload) end rescue MessagePack::UnpackError => error raise UnpackError, error. rescue IOError => error raise UnpackError, "#{error.class.name}, #{error.}" end |