Module: Glossarist::ContextConfiguration
- Included in:
- Rdf::V3::Configuration, V2::Configuration, V3::Configuration
- Defined in:
- lib/glossarist/context_configuration.rb
Instance Method Summary collapse
- #context ⇒ Object
- #context_id ⇒ Object
- #create_context(id:, registry: nil, fallback_to: [context_id], substitutions: []) ⇒ Object
- #populate_context! ⇒ Object
- #register_model(klass, id:) ⇒ Object
- #resolve_model(id) ⇒ Object
Instance Method Details
#context ⇒ Object
9 10 11 |
# File 'lib/glossarist/context_configuration.rb', line 9 def context Lutaml::Model::GlobalContext.context(context_id) end |
#context_id ⇒ Object
5 6 7 |
# File 'lib/glossarist/context_configuration.rb', line 5 def context_id self::CONTEXT_ID end |
#create_context(id:, registry: nil, fallback_to: [context_id], substitutions: []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/glossarist/context_configuration.rb', line 13 def create_context( id:, registry: nil, fallback_to: [context_id], substitutions: [] ) normalized_id = id.to_sym return populate_context! if normalized_id == context_id Lutaml::Model::GlobalContext.unregister_context(normalized_id) if Lutaml::Model::GlobalContext.context(normalized_id) create_type_context( id: normalized_id, registry: registry || Lutaml::Model::TypeRegistry.new, fallback_to: normalize_fallbacks(fallback_to), substitutions: substitutions, ) end |
#populate_context! ⇒ Object
32 33 34 35 |
# File 'lib/glossarist/context_configuration.rb', line 32 def populate_context! Lutaml::Model::GlobalContext.unregister_context(context_id) if context register_models_in(base_type_context) end |
#register_model(klass, id:) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/glossarist/context_configuration.rb', line 37 def register_model(klass, id:) normalized_id = id.to_sym registered_models[normalized_id] = klass (context || populate_base_context).registry.register(normalized_id, klass) klass end |
#resolve_model(id) ⇒ Object
44 45 46 |
# File 'lib/glossarist/context_configuration.rb', line 44 def resolve_model(id) Lutaml::Model::GlobalContext.resolve_type(id, context_id) end |