Class: Zaikio::Loom::EventSerializer

Inherits:
ActiveJob::Serializers::ObjectSerializer
  • Object
show all
Defined in:
lib/zaikio/loom/event_serializer.rb

Instance Method Summary collapse

Instance Method Details

#deserialize(hash) ⇒ Object



12
13
14
15
16
17
# File 'lib/zaikio/loom/event_serializer.rb', line 12

def deserialize(hash)
  name = hash.delete("name")
  timestamp = DateTime.parse(hash.delete("timestamp"))
  hash.delete("_aj_serialized")
  Event.new(name, **hash.symbolize_keys.merge(timestamp: timestamp))
end

#serialize(event) ⇒ Object



8
9
10
# File 'lib/zaikio/loom/event_serializer.rb', line 8

def serialize(event)
  super(event.to_h.stringify_keys)
end

#serialize?(argument) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/zaikio/loom/event_serializer.rb', line 4

def serialize?(argument)
  argument.is_a? Event
end