class Avro::Builder::SchemaSerializerReferenceState

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.

Attributes

references[R]

Public Class Methods

new() click to toggle source
# File lib/avro/builder/schema_serializer_reference_state.rb, line 15
def initialize
  @references = Set.new
end

Public Instance Methods

definition_or_reference(fullname) { || ... } click to toggle source
# File lib/avro/builder/schema_serializer_reference_state.rb, line 19
def definition_or_reference(fullname)
  if references.include?(fullname)
    fullname
  else
    references << fullname
    yield
  end
end