Class: Lutaml::Model::NamespaceBinding
- Inherits:
-
Object
- Object
- Lutaml::Model::NamespaceBinding
- Defined in:
- lib/lutaml/model/register/namespace_binding.rb
Overview
Represents a binding between a register and a namespace.
This enables version-aware type resolution where different namespaces can map to different type implementations.
Instance Attribute Summary collapse
-
#namespace_class ⇒ Class
readonly
The namespace class.
-
#namespace_uri ⇒ String
readonly
The namespace URI.
-
#register_id ⇒ Symbol
readonly
The register ID.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Check equality with another NamespaceBinding.
-
#hash ⇒ Integer
Hash code for use as hash key.
-
#initialize(register_id:, namespace_class:) ⇒ NamespaceBinding
constructor
Create a new namespace binding.
-
#to_s ⇒ String
(also: #inspect)
Human-readable representation.
Constructor Details
#initialize(register_id:, namespace_class:) ⇒ NamespaceBinding
Create a new namespace binding.
38 39 40 41 42 43 44 45 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 38 def initialize(register_id:, namespace_class:) validate_namespace_class!(namespace_class) @register_id = register_id.to_sym @namespace_class = namespace_class @namespace_uri = namespace_class.uri freeze end |
Instance Attribute Details
#namespace_class ⇒ Class (readonly)
Returns The namespace class.
26 27 28 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 26 def namespace_class @namespace_class end |
#namespace_uri ⇒ String (readonly)
Returns The namespace URI.
30 31 32 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 30 def namespace_uri @namespace_uri end |
#register_id ⇒ Symbol (readonly)
Returns The register ID.
22 23 24 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 22 def register_id @register_id end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Check equality with another NamespaceBinding.
52 53 54 55 56 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 52 def ==(other) return false unless other.is_a?(NamespaceBinding) register_id == other.register_id && namespace_uri == other.namespace_uri end |
#hash ⇒ Integer
Hash code for use as hash key.
64 65 66 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 64 def hash [register_id, namespace_uri].hash end |
#to_s ⇒ String Also known as: inspect
Human-readable representation.
72 73 74 |
# File 'lib/lutaml/model/register/namespace_binding.rb', line 72 def to_s "#<#{self.class.name} register=#{register_id} namespace=#{namespace_uri}>" end |