Sha256: ab0cd9f17da15aa17f27fa430902d2d6bc4d6997054de61de3f64aefeec59889

Contents?: true

Size: 662 Bytes

Versions: 43

Compression:

Stored size: 662 Bytes

Contents

module Avromatic
  module Model
    module Attribute

      # This subclass of Virtus::Attribute is used to truncate timestamp values
      # to the supported precision.
      class AbstractTimestamp < Virtus::Attribute
        def coerce(value)
          return value if value.nil? || value_coerced?(value)

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

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

        private

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

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
avromatic-1.0.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.33.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.32.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.32.0.rc0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.31.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.30.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.29.1 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.29.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.28.1 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.27.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.26.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.25.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.24.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.23.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.22.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.21.1 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.21.0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.21.0.rc1 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.21.0.rc0 lib/avromatic/model/attribute/abstract_timestamp.rb
avromatic-0.20.0 lib/avromatic/model/attribute/abstract_timestamp.rb