Class: Lutaml::Model::Schema::RegistryGenerator
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::RegistryGenerator
- Defined in:
- lib/lutaml/model/schema/registry_generator.rb
Overview
Base class for per-format registry generators (one Ruby file that
declares autoloads + a self.register_all that registers every
generated class with the model registry).
Subclasses customize the ERB skeleton (e.g., XSD adds import resolution phases) but inherit the shared module-wrap and autoload/registration emit methods.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_TEMPLATE =
ERB.new(<<~TMPL, trim_mode: "-") # frozen_string_literal: true # Auto-generated central registry for <%= @module_namespace %> <%= module_opening -%> <%= autoload_declarations %> def self.register_all context = Lutaml::Model::GlobalContext.context(:<%= @register_id %>) || Lutaml::Model::GlobalContext.create_context(id: :<%= @register_id %>) <%= registration_body %> end <%= module_closing -%> TMPL
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(model_entries, options) ⇒ RegistryGenerator
constructor
model_entriesis an Array of CompiledOutput::Entry with kind:model.
Constructor Details
#initialize(model_entries, options) ⇒ RegistryGenerator
model_entries is an Array of CompiledOutput::Entry with kind
:model. options[:namespaces] is an Array of :namespace
entries, autoloaded but never registered.
39 40 41 42 43 44 45 |
# File 'lib/lutaml/model/schema/registry_generator.rb', line 39 def initialize(model_entries, ) @classes = model_entries @namespaces = [:namespaces] || [] @module_namespace = [:module_namespace] @register_id = [:register_id] || :default @modules = @module_namespace&.split("::") || [] end |
Class Method Details
.generate(model_entries, options = {}) ⇒ Object
32 33 34 |
# File 'lib/lutaml/model/schema/registry_generator.rb', line 32 def self.generate(model_entries, = {}) new(model_entries, ).generate end |
Instance Method Details
#generate ⇒ Object
47 48 49 50 51 |
# File 'lib/lutaml/model/schema/registry_generator.rb', line 47 def generate return nil unless @module_namespace template.result(binding) end |