Class: Avromatic::Model::Attribute::AbstractTimestamp

Inherits:
Virtus::Attribute
  • Object
show all
Defined in:
lib/avromatic/model/attribute/abstract_timestamp.rb

Overview

This subclass of Virtus::Attribute is used to truncate timestamp values to the supported precision.

Direct Known Subclasses

TimestampMicros, TimestampMillis

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



8
9
10
11
12
# File 'lib/avromatic/model/attribute/abstract_timestamp.rb', line 8

def coerce(value)
  return value if value.nil? || value_coerced?(value)

  value.is_a?(Time) ? coerce_time(value) : value
end

#value_coerced?(_value) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/avromatic/model/attribute/abstract_timestamp.rb', line 14

def value_coerced?(_value)
  raise "#{__method__} must be overridden by #{self.class.name}"
end