Class: Openapi3Parser::Document::ReferenceRegistry
- Inherits:
-
Object
- Object
- Openapi3Parser::Document::ReferenceRegistry
- Defined in:
- lib/openapi3_parser/document/reference_registry.rb
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #factories ⇒ Object
- #factory(object_type, source_location) ⇒ Object
- #freeze ⇒ Object
-
#initialize ⇒ ReferenceRegistry
constructor
A new instance of ReferenceRegistry.
- #register(unbuilt_factory, source_location, reference_factory_context) ⇒ Object
Constructor Details
#initialize ⇒ ReferenceRegistry
Returns a new instance of ReferenceRegistry.
8 9 10 11 |
# File 'lib/openapi3_parser/document/reference_registry.rb', line 8 def initialize @sources = [] @factories_by_type = {} end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
6 7 8 |
# File 'lib/openapi3_parser/document/reference_registry.rb', line 6 def sources @sources end |
Instance Method Details
#factories ⇒ Object
19 20 21 |
# File 'lib/openapi3_parser/document/reference_registry.rb', line 19 def factories factories_by_type.values.flatten end |
#factory(object_type, source_location) ⇒ Object
37 38 39 40 41 |
# File 'lib/openapi3_parser/document/reference_registry.rb', line 37 def factory(object_type, source_location) factories_by_type[object_type]&.find do |f| f.context.source_location == source_location end end |
#freeze ⇒ Object
13 14 15 16 17 |
# File 'lib/openapi3_parser/document/reference_registry.rb', line 13 def freeze sources.freeze factories_by_type.freeze.each(&:freeze) super end |
#register(unbuilt_factory, source_location, reference_factory_context) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/openapi3_parser/document/reference_registry.rb', line 23 def register(unbuilt_factory, source_location, reference_factory_context) register_source(source_location.source) object_type = unbuilt_factory.object_type existing_factory = factory(object_type, source_location) return existing_factory if existing_factory build_factory( unbuilt_factory, source_location, reference_factory_context ).tap { |f| register_factory(object_type, f) } end |