class Rack::Session::SmartCookie::MessagePack
Attributes
factory[R]
Public Class Methods
new() { |factory| ... }
click to toggle source
# File lib/rack/session/smart_cookie.rb, line 45 def initialize # Create our own factory so we don't pollute the global namespace # with our custom type. @factory = ::MessagePack::Factory.new # MessagePack gets custom types 0x80..0xFF # we get 0x60...0x80 @factory.register_type(0x60, Symbol) # user gets 0x00...0x60 yield @factory if block_given? end
Public Instance Methods
decode(bin)
click to toggle source
# File lib/rack/session/smart_cookie.rb, line 62 def decode(bin) return unless bin # https://github.com/msgpack/msgpack-ruby/issues/141 factory.unpacker.feed(bin).read rescue end
encode(data)
click to toggle source
# File lib/rack/session/smart_cookie.rb, line 57 def encode(data) # https://github.com/msgpack/msgpack-ruby/issues/141 factory.packer.write(data).to_str end