class Avromatic::Model::Types::AbstractTimestampType
Constants
- INPUT_CLASSES
- VALUE_CLASSES
Public Instance Methods
coerce(input)
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 20 def coerce(input) if input.nil? || coerced?(input) input elsif input.is_a?(::Time) || input.is_a?(::DateTime) coerce_time(input) else raise ArgumentError.new("Could not coerce '#{input.inspect}' to #{name}") end end
coerced?(value)
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 34 def coerced?(value) # ActiveSupport::TimeWithZone overrides is_a? is to make it look like a Time # even though it's not which can lead to unexpected behavior if we don't force # a coercion value.is_a?(::Time) && value.class != ActiveSupport::TimeWithZone && truncated?(value) end
coercible?(input)
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 30 def coercible?(input) input.nil? || input.is_a?(::Time) || input.is_a?(::DateTime) end
input_classes()
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 16 def input_classes INPUT_CLASSES end
serialize(value, _strict)
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 41 def serialize(value, _strict) value end
value_classes()
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 12 def value_classes VALUE_CLASSES end
Private Instance Methods
coerce_time(_input)
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 51 def coerce_time(_input) raise "#{__method__} must be overridden by #{self.class.name}" end
truncated?(_value)
click to toggle source
# File lib/avromatic/model/types/abstract_timestamp_type.rb, line 47 def truncated?(_value) raise "#{__method__} must be overridden by #{self.class.name}" end