Class: ActiveJob::Serializers::DurationSerializer
- Inherits:
-
ObjectSerializer
- Object
- ObjectSerializer
- ActiveJob::Serializers::DurationSerializer
- Defined in:
- lib/active_job/serializers/duration_serializer.rb
Overview
:nodoc:
Instance Method Summary collapse
Methods inherited from ObjectSerializer
Instance Method Details
#deserialize(hash) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/active_job/serializers/duration_serializer.rb', line 12 def deserialize(hash) value = hash["value"] parts = Arguments.deserialize(hash["parts"]) # `parts` is originally a hash, but will have been flattened to an array by Arguments.serialize klass.new(value, parts.to_h) end |
#serialize(duration) ⇒ Object
6 7 8 9 10 |
# File 'lib/active_job/serializers/duration_serializer.rb', line 6 def serialize(duration) # Ideally duration.parts would be wrapped in an array before passing to Arguments.serialize, # but we continue passing the bare hash for backwards compatibility: super("value" => duration.value, "parts" => Arguments.serialize(duration.parts)) end |