Module: Property::Serialization::Marshal::Encoder

Included in:
Property::Serialization::Marshal, Property::Serialization::Marshal
Defined in:
lib/property/serialization/marshal.rb

Instance Method Summary collapse

Instance Method Details

#decode_properties(string) ⇒ Object

Decode Marshal encoded properties



23
24
25
# File 'lib/property/serialization/marshal.rb', line 23

def decode_properties(string)
  ::Marshal::load(string.unpack('m')[0])
end

#encode_properties(properties) ⇒ Object

Encode properties with Marhsal



16
17
18
19
20
# File 'lib/property/serialization/marshal.rb', line 16

def encode_properties(properties)
  # we limit dump depth to 0 (object only: no instance variables)
  # we have to protect Marshal from serializing instance variables by making a copy
  [::Marshal::dump(Properties[properties])].pack('m*')
end