Class: Lutaml::Xml::NamespaceDeclarationData
- Inherits:
-
Object
- Object
- Lutaml::Xml::NamespaceDeclarationData
- Defined in:
- lib/lutaml/xml/namespace_declaration_data.rb
Overview
Data for a namespace declaration NO XML construction - that’s the adapter’s job
This class maintains MECE responsibility: it only stores declaration data. XML string building belongs in adapters, NOT here.
CRITICAL ARCHITECTURAL PRINCIPLE: This class stores WHAT to declare and HOW to format it (data decisions). Adapters build the actual xmlns=“uri” or xmlns:prefix=“uri” strings.
Instance Attribute Summary collapse
-
#declared_at ⇒ Object
readonly
Returns the value of attribute declared_at.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#namespace_class ⇒ Object
readonly
Returns the value of attribute namespace_class.
-
#prefix_override ⇒ Object
readonly
Returns the value of attribute prefix_override.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Equality check.
-
#attribute_form_default ⇒ Symbol
Get attribute_form_default setting.
-
#declared_here? ⇒ Boolean
Check if declared at this location.
-
#default_format? ⇒ Boolean
Check if default format.
-
#element_form_default ⇒ Symbol
Get element_form_default setting.
-
#from_input? ⇒ Boolean
Check if from parsed input.
-
#has_prefix? ⇒ Boolean
Check if namespace has a prefix defined.
-
#hash ⇒ Integer
Hash code for use in sets/hashes.
-
#inherited? ⇒ Boolean
Check if inherited from parent.
-
#initialize(namespace_class:, format:, declared_at:, prefix_override: nil, source: nil) ⇒ NamespaceDeclarationData
constructor
Initialize namespace declaration data.
-
#inspect ⇒ String
String representation for debugging.
-
#key ⇒ String
Get namespace key for lookups.
-
#local_on_use? ⇒ Boolean
Check if local on use.
-
#prefix ⇒ String?
Get effective prefix (override or default).
-
#prefix_format? ⇒ Boolean
Check if prefix format.
-
#uri ⇒ String
Get namespace URI.
Constructor Details
#initialize(namespace_class:, format:, declared_at:, prefix_override: nil, source: nil) ⇒ NamespaceDeclarationData
Initialize namespace declaration data
24 25 26 27 28 29 30 31 32 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 24 def initialize(namespace_class:, format:, declared_at:, prefix_override: nil, source: nil) @namespace_class = namespace_class @format = format @declared_at = declared_at @prefix_override = prefix_override @source = source validate! end |
Instance Attribute Details
#declared_at ⇒ Object (readonly)
Returns the value of attribute declared_at.
15 16 17 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 15 def declared_at @declared_at end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
15 16 17 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 15 def format @format end |
#namespace_class ⇒ Object (readonly)
Returns the value of attribute namespace_class.
15 16 17 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 15 def namespace_class @namespace_class end |
#prefix_override ⇒ Object (readonly)
Returns the value of attribute prefix_override.
15 16 17 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 15 def prefix_override @prefix_override end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
15 16 17 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 15 def source @source end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Equality check
123 124 125 126 127 128 129 130 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 123 def ==(other) other.is_a?(NamespaceDeclarationData) && other.namespace_class == @namespace_class && other.format == @format && other.declared_at == @declared_at && other.prefix_override == @prefix_override && other.source == @source end |
#attribute_form_default ⇒ Symbol
Get attribute_form_default setting
106 107 108 109 110 111 112 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 106 def attribute_form_default if @namespace_class.respond_to?(:attribute_form_default) @namespace_class.attribute_form_default else :unqualified # W3C default end end |
#declared_here? ⇒ Boolean
Check if declared at this location
48 49 50 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 48 def declared_here? @declared_at == :here end |
#default_format? ⇒ Boolean
Check if default format
42 43 44 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 42 def default_format? @format == :default end |
#element_form_default ⇒ Symbol
Get element_form_default setting
96 97 98 99 100 101 102 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 96 def element_form_default if @namespace_class.respond_to?(:element_form_default) @namespace_class.element_form_default else :qualified # W3C default end end |
#from_input? ⇒ Boolean
Check if from parsed input
66 67 68 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 66 def from_input? @source == :input end |
#has_prefix? ⇒ Boolean
Check if namespace has a prefix defined
90 91 92 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 90 def has_prefix? !prefix.nil? end |
#hash ⇒ Integer
Hash code for use in sets/hashes
136 137 138 139 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 136 def hash [@namespace_class, @format, @declared_at, @prefix_override, @source].hash end |
#inherited? ⇒ Boolean
Check if inherited from parent
54 55 56 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 54 def inherited? @declared_at == :inherited end |
#inspect ⇒ String
String representation for debugging
116 117 118 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 116 def inspect "#<NamespaceDeclarationData #{@namespace_class} format=#{@format} declared_at=#{@declared_at}>" end |
#key ⇒ String
Get namespace key for lookups
84 85 86 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 84 def key @namespace_class.to_key end |
#local_on_use? ⇒ Boolean
Check if local on use
60 61 62 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 60 def local_on_use? @declared_at == :local_on_use end |
#prefix ⇒ String?
Get effective prefix (override or default)
78 79 80 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 78 def prefix @prefix_override || @namespace_class.prefix_default end |
#prefix_format? ⇒ Boolean
Check if prefix format
36 37 38 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 36 def prefix_format? @format == :prefix end |
#uri ⇒ String
Get namespace URI
72 73 74 |
# File 'lib/lutaml/xml/namespace_declaration_data.rb', line 72 def uri @namespace_class.uri end |