mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
23 lines
499 B
Ruby
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
|