Class: Lutaml::Model::Schema::CompiledOutput
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::CompiledOutput
- Defined in:
- lib/lutaml/model/schema/compiled_output.rb
Overview
Pure value object holding the output of compilation. No I/O — just
data. FileWriter / ClassLoader collaborators consume this to perform
the impure parts of to_models. Shared across schema compilers (RNG,
XSD, future formats).
Entries are an ordered list of tagged records, each carrying a
CamelCase class name, a payload (either a Definitions::* spec or a
pre-rendered Ruby source String), and a kind of :model or
:namespace.
:model entries are written to disk AND registered with
register_all. :namespace entries are written and autoloaded but
never registered.
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#module_namespace ⇒ Object
readonly
Returns the value of attribute module_namespace.
-
#register_id ⇒ Object
readonly
Returns the value of attribute register_id.
-
#source_module_namespace ⇒ Object
readonly
Returns the value of attribute source_module_namespace.
Instance Method Summary collapse
-
#initialize(entries:, module_namespace: nil, register_id: :default, source_module_namespace: :inherit) ⇒ CompiledOutput
constructor
module_namespaceis what the central registry file wraps in (and whereregister_alllives). -
#models ⇒ Object
Model-only entries — what the registry generator and ClassLoader iterate when emitting
register_allcalls. -
#namespaces ⇒ Object
Namespace-only entries — autoloaded but never registered.
-
#sources ⇒ Object
Flat
name => Ruby sourcehash covering every entry (models + namespaces).
Constructor Details
#initialize(entries:, module_namespace: nil, register_id: :default, source_module_namespace: :inherit) ⇒ CompiledOutput
module_namespace is what the central registry file wraps in
(and where register_all lives). source_module_namespace
is what the per-class files wrap in — defaults to the same,
but ClassLoader can pass a different value when the caller
asked for unwrapped classes but a registry constant is still
needed to drive autoload.
31 32 33 34 35 36 37 38 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 31 def initialize(entries:, module_namespace: nil, register_id: :default, source_module_namespace: :inherit) @entries = entries @module_namespace = module_namespace @register_id = register_id @source_module_namespace = source_module_namespace == :inherit ? module_namespace : source_module_namespace end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
22 23 24 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 22 def entries @entries end |
#module_namespace ⇒ Object (readonly)
Returns the value of attribute module_namespace.
22 23 24 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 22 def module_namespace @module_namespace end |
#register_id ⇒ Object (readonly)
Returns the value of attribute register_id.
22 23 24 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 22 def register_id @register_id end |
#source_module_namespace ⇒ Object (readonly)
Returns the value of attribute source_module_namespace.
22 23 24 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 22 def source_module_namespace @source_module_namespace end |
Instance Method Details
#models ⇒ Object
Model-only entries — what the registry generator and ClassLoader
iterate when emitting register_all calls.
42 43 44 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 42 def models @models ||= entries.select { |e| e.kind == :model } end |
#namespaces ⇒ Object
Namespace-only entries — autoloaded but never registered.
47 48 49 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 47 def namespaces @namespaces ||= entries.select { |e| e.kind == :namespace } end |
#sources ⇒ Object
Flat name => Ruby source hash covering every entry (models +
namespaces). Used by FileWriter for the per-file write loop and
by RNG / XSD compilers as the public to_models return value.
Class files are rendered against source_module_namespace,
which usually equals module_namespace but differs when the
caller wanted unwrapped class files inside a registry module.
57 58 59 |
# File 'lib/lutaml/model/schema/compiled_output.rb', line 57 def sources @sources ||= entries.to_h { |e| [e.name, source_for(e)] } end |