class ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/active_record/attribute_methods/time_zone_conversion.rbs class ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter def self.new: (ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Timestamp subtype) -> ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter def cast: (Time value) -> ActiveSupport::TimeWithZone def convert_time_to_time_zone: (Time? value) -> ActiveSupport::TimeWithZone? def deserialize: (nil value) -> nil end
:nodoc:
def self.new(subtype)
Experimental RBS support (using type sampling data from the type_fusion project).
def self.new: (ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Timestamp subtype) -> ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter
This signature was generated using 1 sample from 1 application.
def self.new(subtype) self === subtype ? subtype : super end
def cast(value)
Experimental RBS support (using type sampling data from the type_fusion project).
def cast: (Time value) -> ActiveSupport::TimeWithZone
This signature was generated using 5 samples from 1 application.
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_avoiding_infinite_recursion(super) { |v| cast(v) } end end
def convert_time_to_time_zone(value)
Experimental RBS support (using type sampling data from the type_fusion project).
def convert_time_to_time_zone: (Time? value) -> ActiveSupport::TimeWithZone?
This signature was generated using 7 samples from 2 applications.
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_avoiding_infinite_recursion(value) { |v| convert_time_to_time_zone(v) } end end
def deserialize(value)
Experimental RBS support (using type sampling data from the type_fusion project).
def deserialize: (nil value) -> nil
This signature was generated using 4 samples from 1 application.
def deserialize(value) convert_time_to_time_zone(super) end
def map_avoiding_infinite_recursion(value)
def map_avoiding_infinite_recursion(value) map(value) do |v| if value.equal?(v) nil else yield(v) end end end
def set_time_zone_without_conversion(value)
def set_time_zone_without_conversion(value) ::Time.zone.local_to_utc(value).try(:in_time_zone) if value end