Class: ParallelWorkforce::Serializer::Marshal

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_workforce/serializer/marshal.rb

Direct Known Subclasses

JsonMarshal

Instance Method Summary collapse

Instance Method Details

#deserialize(string) ⇒ Object



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

def deserialize(string)
  ::Marshal.load(string)
rescue TypeError => e
  ParallelWorkforce.log(:warn, "#{self.class}: Unable to deserialize string: #{e}", e, *e.backtrace)

  raise ParallelWorkforce::SerializerError.new("Unable to deserialize string: #{e}")
end

#serialize(object) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/parallel_workforce/serializer/marshal.rb', line 4

def serialize(object)
  ::Marshal.dump(object)
rescue TypeError => e
  ParallelWorkforce.log(:error, "#{self.class}: Unable to serialize object: #{e}", e, *e.backtrace)

  raise ParallelWorkforce::SerializerError.new("Unable to serialize object: #{e}")
end