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 convert_time_to_time_zone: (Time? value) -> nil def deserialize: (nil value) -> nil end
:nodoc:
def self.new(subtype)
def self.new(subtype) self === subtype ? subtype : super end
def cast(value)
def cast(value) return if value.nil? if value.is_a?(Hash) set_time_zone_without_conversion(super) elsif value.is_a?(Range) Range.new(user_input_in_time_zone(value.begin), user_input_in_time_zone(value.end), value.exclude_end?) 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) -> nil
This signature was generated using 2 samples from 1 application.
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 elsif value.is_a?(Range) Range.new(convert_time_to_time_zone(value.begin), convert_time_to_time_zone(value.end), value.exclude_end?) 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 1 sample 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