Class: Insights::API::Common::OpenApi::Docs::ComponentCollection
- Inherits:
-
Hash
- Object
- Hash
- Insights::API::Common::OpenApi::Docs::ComponentCollection
- Defined in:
- lib/insights/api/common/open_api/docs/component_collection.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(doc, category) ⇒ ComponentCollection
constructor
A new instance of ComponentCollection.
- #load_definition(name) ⇒ Object
Constructor Details
#initialize(doc, category) ⇒ ComponentCollection
Returns a new instance of ComponentCollection.
9 10 11 12 |
# File 'lib/insights/api/common/open_api/docs/component_collection.rb', line 9 def initialize(doc, category) @doc = doc @category = category end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
7 8 9 |
# File 'lib/insights/api/common/open_api/docs/component_collection.rb', line 7 def doc @doc end |
Instance Method Details
#[](name) ⇒ Object
14 15 16 |
# File 'lib/insights/api/common/open_api/docs/component_collection.rb', line 14 def [](name) super || load_definition(name) end |
#load_definition(name) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/insights/api/common/open_api/docs/component_collection.rb', line 18 def load_definition(name) raw_definition = @doc.content.fetch_path(*@category.split("/"), name) raise ArgumentError, "Failed to find definition for #{name}" unless raw_definition.kind_of?(Hash) definition = substitute_regexes(raw_definition) definition = substitute_references(definition) self[name] = ::Insights::API::Common::OpenApi::Docs::ObjectDefinition.new.replace(definition) end |