Class: Lutaml::Xml::NamespaceScopeConfig
- Inherits:
-
Object
- Object
- Lutaml::Xml::NamespaceScopeConfig
- Defined in:
- lib/lutaml/xml/namespace_scope_config.rb
Overview
Configuration for namespace_scope directive Replaces declare: hash
This class maintains MECE responsibility: it only stores scope configuration. Decision-making about declaration belongs in the planner.
Instance Attribute Summary collapse
-
#declare_mode ⇒ Object
readonly
Returns the value of attribute declare_mode.
-
#namespace_class ⇒ Object
readonly
Returns the value of attribute namespace_class.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Equality check.
-
#always_mode? ⇒ Boolean
Check if this is always mode.
-
#auto_mode? ⇒ Boolean
Check if this is auto mode.
-
#hash ⇒ Integer
Hash code for use in sets/hashes.
-
#initialize(namespace_class, declare_mode = :auto) ⇒ NamespaceScopeConfig
constructor
Initialize namespace scope configuration.
-
#inspect ⇒ String
String representation for debugging.
-
#key ⇒ String
Get namespace key for lookups.
-
#prefix ⇒ String?
Get namespace prefix.
-
#should_declare?(used) ⇒ Boolean
Determine if namespace should be declared based on usage.
-
#uri ⇒ String
Get namespace URI.
Constructor Details
#initialize(namespace_class, declare_mode = :auto) ⇒ NamespaceScopeConfig
Initialize namespace scope configuration
16 17 18 19 20 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 16 def initialize(namespace_class, declare_mode = :auto) @namespace_class = namespace_class @declare_mode = declare_mode validate! end |
Instance Attribute Details
#declare_mode ⇒ Object (readonly)
Returns the value of attribute declare_mode.
11 12 13 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 11 def declare_mode @declare_mode end |
#namespace_class ⇒ Object (readonly)
Returns the value of attribute namespace_class.
11 12 13 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 11 def namespace_class @namespace_class end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Equality check
75 76 77 78 79 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 75 def ==(other) other.is_a?(NamespaceScopeConfig) && other.namespace_class == @namespace_class && other.declare_mode == @declare_mode end |
#always_mode? ⇒ Boolean
Check if this is always mode
44 45 46 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 44 def always_mode? @declare_mode == :always end |
#auto_mode? ⇒ Boolean
Check if this is auto mode
38 39 40 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 38 def auto_mode? @declare_mode == :auto end |
#hash ⇒ Integer
Hash code for use in sets/hashes
85 86 87 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 85 def hash [@namespace_class, @declare_mode].hash end |
#inspect ⇒ String
String representation for debugging
68 69 70 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 68 def inspect "#<NamespaceScopeConfig #{@namespace_class} mode=#{@declare_mode}>" end |
#key ⇒ String
Get namespace key for lookups
50 51 52 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 50 def key @namespace_class.to_key end |
#prefix ⇒ String?
Get namespace prefix
62 63 64 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 62 def prefix @namespace_class.prefix_default end |
#should_declare?(used) ⇒ Boolean
Determine if namespace should be declared based on usage
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 25 def should_declare?(used) case @declare_mode when :always true when :auto used else false end end |
#uri ⇒ String
Get namespace URI
56 57 58 |
# File 'lib/lutaml/xml/namespace_scope_config.rb', line 56 def uri @namespace_class.uri end |