Module: Emittance::Resque::EventSerializer::ActiveRecord
- Defined in:
- lib/emittance/resque/event_serializer/active_record.rb
Overview
Essentially the same as the default serializer, with the added ability to store the metadata for ActiveRecord
objects, so that it will re-fetch the record when the job is dequeued. Will serialize ActiveRecord objects
even if inside of an array (or nested array), or if added as a value in a hash.
Class Method Summary collapse
Class Method Details
.deserialize(event_hash) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/emittance/resque/event_serializer/active_record.rb', line 22 def deserialize(event_hash) identifier = event_hash['identifier'] event_klass = Emittance::EventLookup.find_event_klass(identifier) emitter = deserialize_object(event_hash['emitter']) = (event_hash['timestamp']) payload = deserialize_object(event_hash['payload']) event_klass.new(emitter, , payload) end |
.serialize(event) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/emittance/resque/event_serializer/active_record.rb', line 13 def serialize(event) { identifier: event.identifiers.first, emitter: serialize_object(event.emitter), timestamp: (event.), payload: serialize_object(event.payload) } end |