Class: Nanite::Serializer

Inherits:
Object show all
Defined in:
lib/nanite/serializer.rb

Defined Under Namespace

Classes: SerializationError

Instance Method Summary collapse

Constructor Details

#initialize(preferred_format = "marshal") ⇒ Serializer

SerializationError



12
13
14
15
16
17
# File 'lib/nanite/serializer.rb', line 12

def initialize(preferred_format="marshal")
  preferred_format ||= "marshal"
  preferred_serializer = SERIALIZERS[preferred_format.to_sym]
  @serializers = SERIALIZERS.values.clone
  @serializers.unshift(@serializers.delete(preferred_serializer)) if preferred_serializer
end

Instance Method Details

#dump(packet) ⇒ Object



19
20
21
# File 'lib/nanite/serializer.rb', line 19

def dump(packet)
  cascade_serializers(:dump, packet)
end

#load(packet) ⇒ Object



23
24
25
# File 'lib/nanite/serializer.rb', line 23

def load(packet)
  cascade_serializers(:load, packet)
end