Module: Lutaml::Xml::Type::Configurable::ClassMethods
- Defined in:
- lib/lutaml/xml/type/configurable.rb
Overview
Class methods for XML configuration
Instance Method Summary collapse
-
#create_xml_mapping ⇒ Lutaml::Xml::Type::ValueXmlMapping
Create a new XML mapping instance.
-
#default_xsd_type ⇒ String
Default XSD type for this Value type.
-
#inherit_xml_mapping_from_parent ⇒ Lutaml::Xml::Type::ValueXmlMapping
Create a new XML mapping, inheriting from parent if available.
-
#inherited_namespace ⇒ Class, ...
Get inherited namespace from parent class.
-
#inherited_xsd_type ⇒ String?
Get inherited xsd_type from parent class.
-
#namespace_class ⇒ Class, ...
Get the namespace class for this Value type.
-
#namespace_prefix ⇒ String?
Get the default namespace prefix for this Value type.
-
#namespace_uri ⇒ String?
Get the namespace URI for this Value type.
-
#xml { ... } ⇒ Lutaml::Xml::Type::ValueXmlMapping
XML configuration block for Value types.
-
#xml_mapping ⇒ Lutaml::Xml::Type::ValueXmlMapping?
Get the XML mapping for this Value type.
-
#xsd_type(type_name = nil) ⇒ String
Class-level directive to set the XSD type name.
Instance Method Details
#create_xml_mapping ⇒ Lutaml::Xml::Type::ValueXmlMapping
Create a new XML mapping instance
150 151 152 |
# File 'lib/lutaml/xml/type/configurable.rb', line 150 def create_xml_mapping Lutaml::Xml::Type::ValueXmlMapping.new end |
#default_xsd_type ⇒ String
Default XSD type for this Value type
Override in subclasses to provide specific default XSD types.
130 131 132 |
# File 'lib/lutaml/xml/type/configurable.rb', line 130 def default_xsd_type "xs:anyType" end |
#inherit_xml_mapping_from_parent ⇒ Lutaml::Xml::Type::ValueXmlMapping
Create a new XML mapping, inheriting from parent if available
137 138 139 140 141 142 143 144 145 |
# File 'lib/lutaml/xml/type/configurable.rb', line 137 def inherit_xml_mapping_from_parent return create_xml_mapping if superclass == Lutaml::Model::Type::Value return create_xml_mapping unless superclass.respond_to?(:xml_mapping) parent_mapping = superclass.xml_mapping return create_xml_mapping unless parent_mapping parent_mapping.deep_dup end |
#inherited_namespace ⇒ Class, ...
Get inherited namespace from parent class
117 118 119 120 121 122 123 |
# File 'lib/lutaml/xml/type/configurable.rb', line 117 def inherited_namespace return nil if superclass == Lutaml::Model::Type::Value return nil unless superclass.respond_to?(:xml_mapping) parent_mapping = superclass.xml_mapping parent_mapping&.namespace_class || superclass.inherited_namespace end |
#inherited_xsd_type ⇒ String?
Get inherited xsd_type from parent class
105 106 107 108 109 110 111 112 |
# File 'lib/lutaml/xml/type/configurable.rb', line 105 def inherited_xsd_type return nil if superclass == Lutaml::Model::Type::Value return nil unless superclass.respond_to?(:xsd_type) # Get parent's @xsd_type directly (not default_xsd_type) parent_xsd = superclass.instance_variable_get(:@xsd_type) parent_xsd || superclass.inherited_xsd_type end |
#namespace_class ⇒ Class, ...
Get the namespace class for this Value type
84 85 86 |
# File 'lib/lutaml/xml/type/configurable.rb', line 84 def namespace_class xml_mapping&.namespace_class || inherited_namespace end |
#namespace_prefix ⇒ String?
Get the default namespace prefix for this Value type
73 74 75 76 77 78 79 |
# File 'lib/lutaml/xml/type/configurable.rb', line 73 def namespace_prefix ns = namespace_class return nil unless ns return nil if %i[blank inherit].include?(ns) ns.prefix_default end |
#namespace_uri ⇒ String?
Get the namespace URI for this Value type
62 63 64 65 66 67 68 |
# File 'lib/lutaml/xml/type/configurable.rb', line 62 def namespace_uri ns = namespace_class return nil unless ns return nil if %i[blank inherit].include?(ns) ns.uri end |
#xml { ... } ⇒ Lutaml::Xml::Type::ValueXmlMapping
XML configuration block for Value types
Provides unified XML configuration API for Type classes. Supports inheritance from parent types.
44 45 46 47 48 49 50 |
# File 'lib/lutaml/xml/type/configurable.rb', line 44 def xml(&block) if block @xml_mapping ||= inherit_xml_mapping_from_parent # rubocop:disable Naming/MemoizedInstanceVariableName @xml_mapping.instance_eval(&block) end @xml_mapping ||= inherit_xml_mapping_from_parent # rubocop:disable Naming/MemoizedInstanceVariableName end |
#xml_mapping ⇒ Lutaml::Xml::Type::ValueXmlMapping?
Get the XML mapping for this Value type
55 56 57 |
# File 'lib/lutaml/xml/type/configurable.rb', line 55 def xml_mapping @xml_mapping end |
#xsd_type(type_name = nil) ⇒ String
Class-level directive to set the XSD type name
97 98 99 100 |
# File 'lib/lutaml/xml/type/configurable.rb', line 97 def xsd_type(type_name = nil) @xsd_type = type_name if type_name @xsd_type || inherited_xsd_type || default_xsd_type end |