Class: ActiveJob::Serializers::DurationSerializer

Inherits:
ObjectSerializer show all
Defined in:
lib/rails_6_polyfills/activejob/serializers.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from ObjectSerializer

#serialize?

Instance Method Details

#deserialize(hash) ⇒ Object



115
116
117
118
119
120
# File 'lib/rails_6_polyfills/activejob/serializers.rb', line 115

def deserialize(hash)
  value = hash["value"]
  parts = Arguments.deserialize(hash["parts"])

  klass.new(value, parts)
end

#serialize(duration) ⇒ Object



111
112
113
# File 'lib/rails_6_polyfills/activejob/serializers.rb', line 111

def serialize(duration)
  super("value" => duration.value, "parts" => Arguments.serialize(duration.parts.each_with_object({}) { |v, s| s[v.first.to_s] = v.last }))
end