Class: Lutaml::Lml::DocumentBuilder
- Inherits:
-
Object
- Object
- Lutaml::Lml::DocumentBuilder
- Defined in:
- lib/lutaml/lml/document_builder.rb
Constant Summary collapse
- DEFAULT_REGISTRY =
Default registry: builder keys → LML model classes. Callers needing a different mapping can pass their own registry to ‘new`; this constant documents the default composition.
{ document: ::Lutaml::Lml::Document, package: ::Lutaml::Lml::Package, class: ::Lutaml::Lml::UmlClass, enum: ::Lutaml::Lml::Enum, data_type: ::Lutaml::Lml::DataType, diagram: ::Lutaml::Lml::Diagram, attribute: ::Lutaml::Lml::TopElementAttribute, cardinality: ::Lutaml::Lml::Cardinality, association: ::Lutaml::Lml::Association, operation: ::Lutaml::Lml::Operation, constraint: ::Lutaml::Lml::Constraint, value: ::Lutaml::Lml::Value, view_import: ::Lutaml::Lml::ViewImport, view_filter: ::Lutaml::Lml::ViewFilter }.freeze
- FACTORY_KEYS =
%i[ document package class enum data_type diagram view_import view_filter attribute association operation constraint value cardinality ].freeze
- MEMBER_KEY_MAP =
{ packages: :package, classes: :class, enums: :enum, data_types: :data_type, diagrams: :diagram, view_imports: :view_import, attributes: :attribute, associations: :association, operations: :operation, constraints: :constraint, values: :value }.freeze
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #build(key, hash) ⇒ Object
-
#initialize(registry = DEFAULT_REGISTRY) ⇒ DocumentBuilder
constructor
A new instance of DocumentBuilder.
Constructor Details
#initialize(registry = DEFAULT_REGISTRY) ⇒ DocumentBuilder
Returns a new instance of DocumentBuilder.
28 29 30 |
# File 'lib/lutaml/lml/document_builder.rb', line 28 def initialize(registry = DEFAULT_REGISTRY) @registry = registry end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
26 27 28 |
# File 'lib/lutaml/lml/document_builder.rb', line 26 def registry @registry end |
Instance Method Details
#build(key, hash) ⇒ Object
55 56 57 |
# File 'lib/lutaml/lml/document_builder.rb', line 55 def build(key, hash) @registry.fetch(key).new.tap { |model| set_model(model, hash) } end |