Module: Xmi::NamespaceRegistry
- Defined in:
- lib/xmi/namespace_registry.rb
Overview
Registry for mapping namespace URIs to namespace classes
This module provides a central registry for namespace classes, allowing dynamic lookup of namespace classes by URI.
Class Method Summary collapse
-
.bootstrap! ⇒ Object
Bootstrap the registry with all known OMG and Sparx namespaces.
-
.clear ⇒ Object
Clear the registry (mainly for testing).
-
.register(uri, namespace_class) ⇒ Object
Register a URI-to-class mapping.
-
.registered?(uri) ⇒ Boolean
Check if a URI is registered.
-
.registered_uris ⇒ Array<String>
Get all registered URIs.
-
.resolve(uri) ⇒ Class?
Resolve a namespace class by URI.
-
.uri_map ⇒ Hash<String, Class>
Get the URI-to-class mapping.
Class Method Details
.bootstrap! ⇒ Object
Bootstrap the registry with all known OMG and Sparx namespaces
This method registers all known namespace URIs from the Xmi::Namespace::Omg and Xmi::Namespace::Sparx modules.
57 58 59 60 |
# File 'lib/xmi/namespace_registry.rb', line 57 def bootstrap! register_omg_namespaces! register_sparx_namespaces! end |
.clear ⇒ Object
Clear the registry (mainly for testing)
49 50 51 |
# File 'lib/xmi/namespace_registry.rb', line 49 def clear @uri_map = {} end |
.register(uri, namespace_class) ⇒ Object
Register a URI-to-class mapping
21 22 23 |
# File 'lib/xmi/namespace_registry.rb', line 21 def register(uri, namespace_class) uri_map[uri] = namespace_class end |
.registered?(uri) ⇒ Boolean
Check if a URI is registered
37 38 39 |
# File 'lib/xmi/namespace_registry.rb', line 37 def registered?(uri) uri_map.key?(uri) end |
.registered_uris ⇒ Array<String>
Get all registered URIs
44 45 46 |
# File 'lib/xmi/namespace_registry.rb', line 44 def registered_uris uri_map.keys end |
.resolve(uri) ⇒ Class?
Resolve a namespace class by URI
29 30 31 |
# File 'lib/xmi/namespace_registry.rb', line 29 def resolve(uri) uri_map[uri] end |
.uri_map ⇒ Hash<String, Class>
Get the URI-to-class mapping
13 14 15 |
# File 'lib/xmi/namespace_registry.rb', line 13 def uri_map @uri_map ||= {} end |