Class: Odin::Resolver::ImportResolver
- Inherits:
-
Object
- Object
- Odin::Resolver::ImportResolver
- Defined in:
- lib/odin/resolver/import_resolver.rb
Constant Summary collapse
- MAX_IMPORT_DEPTH =
32- MAX_TOTAL_IMPORTS =
1000
Instance Method Summary collapse
-
#initialize(loader: nil) ⇒ ImportResolver
constructor
A new instance of ImportResolver.
-
#resolve(schema, base_path: ".") ⇒ Object
Resolve all imports in a schema, returning a flattened schema.
Constructor Details
#initialize(loader: nil) ⇒ ImportResolver
Returns a new instance of ImportResolver.
11 12 13 14 15 |
# File 'lib/odin/resolver/import_resolver.rb', line 11 def initialize(loader: nil) @loader = loader || method(:default_loader) @resolved_paths = Set.new @total_loaded = 0 end |
Instance Method Details
#resolve(schema, base_path: ".") ⇒ Object
Resolve all imports in a schema, returning a flattened schema
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/odin/resolver/import_resolver.rb', line 18 def resolve(schema, base_path: ".") return schema if schema.imports.empty? imported_schemas = [] schema.imports.each do |imp| resolve_import(imp, base_path, imported_schemas, depth: 0) end flatten(schema, imported_schemas) end |