Class: Lutaml::Model::Schema::ClassLoader
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::ClassLoader
- Defined in:
- lib/lutaml/model/schema/class_loader.rb
Overview
Writes a CompiledOutput to a temporary directory, requires the
registry, and runs register_all so the generated classes are
loaded into a real module the caller can use immediately. Shared
between XSD and RNG compilers.
Constant Summary collapse
- DEFAULT_NAMESPACE =
"GeneratedModels"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(output, registry_generator) ⇒ ClassLoader
constructor
A new instance of ClassLoader.
- #load ⇒ Object
Constructor Details
#initialize(output, registry_generator) ⇒ ClassLoader
Returns a new instance of ClassLoader.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lutaml/model/schema/class_loader.rb', line 22 def initialize(output, registry_generator) # ClassLoader needs a module to host the registry constant # (so `register_all` has a home). If the caller wanted # unwrapped class files, we still force a registry module — # but we pin `source_module_namespace` to what they asked for, # so per-class files keep their original wrapping. @output = CompiledOutput.new( entries: output.entries, module_namespace: output.module_namespace || DEFAULT_NAMESPACE, register_id: output.register_id, source_module_namespace: output.module_namespace, ) @registry_generator = registry_generator end |
Class Method Details
.load(output, registry_generator: RegistryGenerator) ⇒ Object
18 19 20 |
# File 'lib/lutaml/model/schema/class_loader.rb', line 18 def self.load(output, registry_generator: RegistryGenerator) new(output, registry_generator).load end |
Instance Method Details
#load ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/lutaml/model/schema/class_loader.rb', line 37 def load Dir.mktmpdir do |dir| FileWriter.write(@output, dir, registry_generator: @registry_generator) require File.join(dir, "#{registry_basename}_registry") call_register_all end end |