Module: ActiveSupport::MessagePack::Serializer
- Included in:
 - ActiveSupport::MessagePack, CacheSerializer
 
- Defined in:
 - lib/active_support/message_pack/serializer.rb
 
Overview
:nodoc:
Constant Summary collapse
- SIGNATURE =
          
128.to_msgpack
 "\xCC\x80".b.freeze
- SIGNATURE_INT =
 128
Instance Method Summary collapse
- #dump(object) ⇒ Object
 - #load(dumped) ⇒ Object
 - #message_pack_factory ⇒ Object
 - #message_pack_factory=(factory) ⇒ Object
 - #signature?(dumped) ⇒ Boolean
 - #warmup ⇒ Object
 
Instance Method Details
#dump(object) ⇒ Object
      11 12 13 14 15 16 17  | 
    
      # File 'lib/active_support/message_pack/serializer.rb', line 11 def dump(object) .packer do |packer| packer.write(SIGNATURE_INT) packer.write(object) packer.full_pack end end  | 
  
#load(dumped) ⇒ Object
      19 20 21 22 23 24 25  | 
    
      # File 'lib/active_support/message_pack/serializer.rb', line 19 def load(dumped) .unpacker do |unpacker| unpacker.feed_reference(dumped) raise "Invalid serialization format" unless unpacker.read == SIGNATURE_INT unpacker.full_unpack end end  | 
  
#message_pack_factory ⇒ Object
      31 32 33  | 
    
      # File 'lib/active_support/message_pack/serializer.rb', line 31 def @message_pack_factory ||= ::MessagePack::Factory.new end  | 
  
#message_pack_factory=(factory) ⇒ Object
      35 36 37 38  | 
    
      # File 'lib/active_support/message_pack/serializer.rb', line 35 def (factory) @message_pack_pool = nil @message_pack_factory = factory end  | 
  
#signature?(dumped) ⇒ Boolean
      27 28 29  | 
    
      # File 'lib/active_support/message_pack/serializer.rb', line 27 def signature?(dumped) dumped.getbyte(0) == SIGNATURE.getbyte(0) && dumped.getbyte(1) == SIGNATURE.getbyte(1) end  | 
  
#warmup ⇒ Object
      42 43 44  | 
    
      # File 'lib/active_support/message_pack/serializer.rb', line 42 def warmup # eagerly compute end  |