Class: ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActiveModel::Type::Value
|
Defined in: | activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb |
Class Method Summary
- .new(subtype) ⇒ TimeZoneConverter constructor
::ActiveModel::Type::Value
- Inherited
.new | Initializes a type with three basic configuration settings: precision, limit, and scale. |
Instance Attribute Summary
::ActiveModel::Type::Value
- Inherited
#limit, #precision, #scale, | |
#binary? | These predicates are not documented, as I need to look further into their use, and see if they can be removed entirely. |
#mutable?, #serialized? |
Instance Method Summary
- #==(other)
- #cast(value)
- #deserialize(value)
- #convert_time_to_time_zone(value) private
- #set_time_zone_without_conversion(value) private
::ActiveModel::Type::Value
- Inherited
#==, #as_json, #assert_valid_value, | |
#cast |
|
#changed? | Determines whether a value has changed for dirty checking. |
#changed_in_place? | Determines whether the mutable value has been modified since it was read. |
#deserialize | Converts a value from database input to the appropriate ruby type. |
#eql? | Alias for ActiveModel::Type::Value#==. |
#hash, | |
#serializable? | Returns true if this type can convert |
#serialize | Casts a value from the ruby type to a type that the database knows how to understand. |
#type | Returns the unique type name as a |
#cast_value | Convenience method for types which do not need separate type casting behavior for user and database inputs. |
#force_equality?, #map, | |
#type_cast_for_schema |
|
#value_constructed_by_mass_assignment? |
::ActiveModel::Type::SerializeCastValue
- Included
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 35
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 super(user_input_in_time_zone(value)) || super 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 40
def convert_time_to_time_zone(value) return if value.nil? if value.acts_like?(:time) value.in_time_zone 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