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.
15 16 17 |
# File 'lib/avro/builder/schema_serializer_reference_state.rb', line 15 def initialize @references = Set.new end |
Instance Method Details
#definition_or_reference(fullname) ⇒ Object
19 20 21 22 23 24 25 26 |
# 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 |