Sha256: c79e06dc07d56e9513b8dcaf572963ce8c5c6ab84932d1d2fe44fca6a283fc06

Contents?: true

Size: 702 Bytes

Versions: 7

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module Avro
  module Builder

    # This class is used to keep track of references to each named type while
    # generating an Avro JSON schema. Only the first reference to the type
    # can include all of details of the definition. All subsequent references
    # must use the full name for the type.
    class SchemaSerializerReferenceState

      attr_reader :references
      private :references

      def initialize
        @references = Set.new
      end

      def definition_or_reference(fullname)
        if references.include?(fullname)
          fullname
        else
          references << fullname
          yield
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
avro-builder-2.1.0 lib/avro/builder/schema_serializer_reference_state.rb
avro-builder-2.0.0 lib/avro/builder/schema_serializer_reference_state.rb
avro-builder-1.1.0 lib/avro/builder/schema_serializer_reference_state.rb
avro-builder-1.0.1 lib/avro/builder/schema_serializer_reference_state.rb
avro-builder-1.0.0 lib/avro/builder/schema_serializer_reference_state.rb
avro-builder-0.17.0 lib/avro/builder/schema_serializer_reference_state.rb
avro-builder-0.16.2 lib/avro/builder/schema_serializer_reference_state.rb