Class: ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
|
|
| Inherits: | Object |
| Defined in: | activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb |
Class Method Summary
- .new(subtype) ⇒ TimeZoneConverter constructor
Instance Attribute Summary
::ActiveRecord::Type::QueryPredicates::Decorator - Included
::ActiveRecord::Type::QueryPredicates - Included
Instance Method Summary
- #==(other)
- #cast(value)
- #deserialize(value)
- #subtype
- #convert_time_to_time_zone(value) private
- #set_time_zone_without_conversion(value) private
::ActiveRecord::Type::QueryPredicates::Decorator - Included
::ActiveRecord::Type::QueryPredicates - Included
| #comparison_expression | Converts a stored attribute or serialized query value into the expression on which comparisons are performed. |
Constructor Details
.new(subtype) ⇒ TimeZoneConverter
Instance Method Details
#==(other)
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 45
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 23
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 50
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 19
def deserialize(value) convert_time_to_time_zone(super) end
#set_time_zone_without_conversion(value) (private)
[ GitHub ]#subtype
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb', line 15
def subtype __getobj__ end