Class: ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb |
Class Method Summary
- .new(subtype) ⇒ TimeZoneConverter constructor
Instance Method Summary
Constructor Details
.new(subtype) ⇒ TimeZoneConverter
# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 9
def self.new(subtype) self === subtype ? subtype : super end
Instance Method Details
#==(other)
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 39
def ==(other) other.is_a?(self.class) && __getobj__ == other.__getobj__ end
#cast(value)
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 17
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 result = super(__getobj__.user_input_in_time_zone(value)) || super if result && type == :time result = result.change(year: 2000, month: 1, day: 1) end result rescue ArgumentError nil end elsif value.respond_to?(:infinite?) && value.infinite? value else map(super) { |v| cast(v) } end end
#convert_time_to_time_zone(value) (private)
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 44
def convert_time_to_time_zone(value) return if value.nil? if value.acts_like?(:time) converted = value.in_time_zone if type == :time && converted converted = converted.change(year: 2000, month: 1, day: 1) end converted elsif value.respond_to?(:infinite?) && value.infinite? value else map(value) { |v| convert_time_to_time_zone(v) } end end
#deserialize(value)
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 13
def deserialize(value) convert_time_to_time_zone(super) end