Class: ActiveJob::Serializers::TimeWithZoneSerializer

Inherits:
ObjectSerializer show all
Defined in:
lib/active_job/serializers/time_with_zone_serializer.rb

Overview

:nodoc:

Constant Summary collapse

NANO_PRECISION =
9

Instance Method Summary collapse

Methods inherited from ObjectSerializer

#serialize?

Instance Method Details

#deserialize(hash) ⇒ Object



15
16
17
# File 'lib/active_job/serializers/time_with_zone_serializer.rb', line 15

def deserialize(hash)
  Time.iso8601(hash["value"]).in_time_zone(hash["time_zone"] || Time.zone)
end

#serialize(time_with_zone) ⇒ Object



8
9
10
11
12
13
# File 'lib/active_job/serializers/time_with_zone_serializer.rb', line 8

def serialize(time_with_zone)
  super(
    "value" => time_with_zone.iso8601(NANO_PRECISION),
    "time_zone" => time_with_zone.time_zone.tzinfo.name
  )
end