Sha256: 49a05521fae97ec47646523b649cdb73b78eaf312999c8b1243c9b8dca57c368

Contents?: true

Size: 786 Bytes

Versions: 15

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

require 'avromatic/model/types/abstract_type'

module Avromatic
  module Model
    module Types
      class NullType < AbstractType
        VALUE_CLASSES = [::NilClass].freeze

        def value_classes
          VALUE_CLASSES
        end

        def name
          'null'
        end

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

        def coercible?(input)
          input.nil?
        end

        alias_method :coerced?, :coercible?

        def serialize(_value, _strict)
          nil
        end

        def referenced_model_classes
          EMPTY_ARRAY
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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