Class: ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter

Inherits:
Type::Value
  • Object
show all
Defined in:
lib/active_record/attribute_methods/time_zone_conversion.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_record/attribute_methods/time_zone_conversion.rb', line 11

def cast(value)
  return if value.nil?

  if value.is_a?(Hash)
    set_time_zone_without_conversion(super)
  elsif value.respond_to?(:in_time_zone)
    begin
      super(user_input_in_time_zone(value)) || super
    rescue ArgumentError
      nil
    end
  else
    map_avoiding_infinite_recursion(super) { |v| cast(v) }
  end
end

#deserialize(value) ⇒ Object



7
8
9
# File 'lib/active_record/attribute_methods/time_zone_conversion.rb', line 7

def deserialize(value)
  convert_time_to_time_zone(super)
end