Class: Avro::Builder::SchemaSerializerReferenceState
- Inherits:
-
Object
- Object
- Avro::Builder::SchemaSerializerReferenceState
- 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
- #definition_or_reference(fullname) ⇒ Object
-
#initialize ⇒ SchemaSerializerReferenceState
constructor
A new instance of SchemaSerializerReferenceState.
Constructor Details
#initialize ⇒ SchemaSerializerReferenceState
Returns a new instance of SchemaSerializerReferenceState.
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 |