Class: Avro::Builder::SchemaSerializerReferenceState

Inherits:
Object
  • Object
show all
Defined in:
lib/avro/builder/schema_serializer_reference_state.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initializeSchemaSerializerReferenceState


13
14
15
# File 'lib/avro/builder/schema_serializer_reference_state.rb', line 13

def initialize
  @references = Set.new
end

Instance Method Details

#definition_or_reference(fullname) ⇒ Object


17
18
19
20
21
22
23
24
# File 'lib/avro/builder/schema_serializer_reference_state.rb', line 17

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