Class: ParallelWorkforce::Serializer::JsonMarshal

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

Instance Method Summary collapse

Instance Method Details

#deserialize(string) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/parallel_workforce/serializer/json_marshal.rb', line 8

def deserialize(string)
  super(JSON.parse(string)['value'])
rescue JSON::ParserError => 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
# File 'lib/parallel_workforce/serializer/json_marshal.rb', line 4

def serialize(object)
  JSON.dump(value: super(object)) # super always returns a String
end