1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/lib/active_job/serializers/duration_serializer.rb

24 lines
508 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-02-09 15:45:11 -05:00
module ActiveJob
module Serializers
class DurationSerializer < ObjectSerializer # :nodoc:
def serialize(duration)
super("value" => duration.value, "parts" => Arguments.serialize(duration.parts))
end
2018-02-09 15:45:11 -05:00
def deserialize(hash)
value = hash["value"]
parts = Arguments.deserialize(hash["parts"])
2018-02-09 15:45:11 -05:00
klass.new(value, parts)
end
2018-02-09 15:45:11 -05:00
private
2018-02-09 15:45:11 -05:00
def klass
ActiveSupport::Duration
end
end
end
end