Sha256: 0476350b81b9e37e7756a5d0b6f1d4af7b512ec23d7785d197166d5be0267959

Contents?: true

Size: 849 Bytes

Versions: 4

Compression:

Stored size: 849 Bytes

Contents

module Avro
  module Builder
    module Types
      # Base class for simple types. The type name is specified when the
      # type is constructed. The type has no additional attributes, and
      # the type is serialized as just the type name.
      class Type
        include Avro::Builder::DslAttributes

        attr_reader :type_name
        attr_accessor :field, :builder

        def initialize(type_name)
          @type_name = type_name
        end

        def serialize(_reference_state)
          type_name
        end

        def namespace
          nil
        end

        def configure_options(_options = {})
          # No-op
        end

        # Optional fields are represented as a union of the type with :null.
        def self.union_with_null(serialized)
          [:null, serialized]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
avro-builder-0.3.2 lib/avro/builder/types/type.rb
avro-builder-0.3.1 lib/avro/builder/types/type.rb
avro-builder-0.3.0 lib/avro/builder/types/type.rb
avro-builder-0.2.0 lib/avro/builder/types/type.rb