Sha256: d8a7a0d037397343281f64bd92bd18721d028956b733cf5d0569fa6e08063975

Contents?: true

Size: 846 Bytes

Versions: 14

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

require 'avromatic/model/types/abstract_type'

module Avromatic
  module Model
    module Types
      class IntegerType < AbstractType
        VALUE_CLASSES = [::Integer].freeze

        def value_classes
          VALUE_CLASSES
        end

        def name
          'integer'
        end

        def coerce(input)
          if input.nil? || input.is_a?(::Integer)
            input
          else
            raise ArgumentError.new("Could not coerce '#{input.inspect}' to #{name}")
          end
        end

        def coercible?(input)
          input.nil? || input.is_a?(::Integer)
        end

        alias_method :coerced?, :coercible?

        def serialize(value, _strict)
          value
        end

        def referenced_model_classes
          EMPTY_ARRAY
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
avromatic-5.1.0 lib/avromatic/model/types/integer_type.rb
avromatic-5.0.0 lib/avromatic/model/types/integer_type.rb
avromatic-4.3.0 lib/avromatic/model/types/integer_type.rb
avromatic-4.2.0 lib/avromatic/model/types/integer_type.rb
avromatic-4.1.1 lib/avromatic/model/types/integer_type.rb
avromatic-4.1.0 lib/avromatic/model/types/integer_type.rb
avromatic-4.0.0 lib/avromatic/model/types/integer_type.rb
avromatic-3.0.2 lib/avromatic/model/types/integer_type.rb
avromatic-3.0.1 lib/avromatic/model/types/integer_type.rb
avromatic-3.0.0 lib/avromatic/model/types/integer_type.rb
avromatic-2.4.0 lib/avromatic/model/types/integer_type.rb
avromatic-2.3.0 lib/avromatic/model/types/integer_type.rb
avromatic-2.2.6 lib/avromatic/model/types/integer_type.rb
avromatic-2.2.5 lib/avromatic/model/types/integer_type.rb