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/range_serializer.rb

23 lines
499 B
Ruby

# frozen_string_literal: true
module ActiveJob
module Serializers
class RangeSerializer < ObjectSerializer
KEYS = %w[begin end exclude_end].freeze
def serialize(range)
args = Arguments.serialize([range.begin, range.end, range.exclude_end?])
super(KEYS.zip(args).to_h)
end
def deserialize(hash)
klass.new(*Arguments.deserialize(hash.values_at(*KEYS)))
end
private
def klass
::Range
end
end
end
end