Module: GlobalSession::Encoding::Msgpack

Defined in:
lib/global_session/encoding.rb

Overview

Wrapper module for MessagePack that makes it conform to the standard load/dump interface for serializers.

Class Method Summary collapse

Class Method Details

.dump(object) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/global_session/encoding.rb', line 77

def self.dump(object)
  if object.respond_to?(:to_msgpack)
    object.to_msgpack
  else
    raise NotImplementedError, "#to_msgpack unavailable; please install 'msgpack' gem to enable this optional functionality"
  end
end

.load(binary) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/global_session/encoding.rb', line 69

def self.load(binary)
  if defined?(MessagePack)
    MessagePack.unpack(binary)
  else
    raise NotImplementedError, "::MessagePack undefined; please install 'msgpack' gem to enable this optional functionality"
  end
end