Module: Omml::Configuration::ContextRegistry
- Included in:
- Omml::Configuration
- Defined in:
- lib/omml/configuration/context_registry.rb
Overview
Extended only by Omml::Configuration together with the sibling modules.
Instance Method Summary collapse
- #context(id = context_id) ⇒ Object
- #create_context(id:, registry: nil, fallback_to: [context_id], substitutions: []) ⇒ Object
- #populate_context! ⇒ Object
- #require_context!(id = context_id) ⇒ Object
- #reset_context!(id: context_id) ⇒ Object
Instance Method Details
#context(id = context_id) ⇒ Object
7 8 9 |
# File 'lib/omml/configuration/context_registry.rb', line 7 def context(id = context_id) Lutaml::Model::GlobalContext.context(id.to_sym) end |
#create_context(id:, registry: nil, fallback_to: [context_id], substitutions: []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/omml/configuration/context_registry.rb', line 11 def create_context(id:, registry: nil, fallback_to: [context_id], substitutions: []) normalized_id = normalize_context_id(id) if default_context_id?(normalized_id) return create_default_context(registry, fallback_to, substitutions) end create_custom_context( id: normalized_id, registry: registry, fallback_to: fallback_to, substitutions: substitutions ) end |
#populate_context! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/omml/configuration/context_registry.rb', line 25 def populate_context! # Trigger the model manifest autoload before replaying registrations. Omml.const_get(:Models) reset_context! register_models_in(populate_base_context) end |
#require_context!(id = context_id) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/omml/configuration/context_registry.rb', line 32 def require_context!(id = context_id) normalized_id = id.to_sym type_context = context(normalized_id) return type_context if type_context raise Omml::Errors::MissingContextError, normalized_id end |
#reset_context!(id: context_id) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/omml/configuration/context_registry.rb', line 40 def reset_context!(id: context_id) normalized_id = normalize_context_id(id) existing_context = Lutaml::Model::GlobalContext.context(normalized_id) return unless existing_context Lutaml::Model::GlobalContext.unregister_context(normalized_id) end |