Module: Lutaml::Xml::Configurable::ClassMethods
- Defined in:
- lib/lutaml/xml/configurable.rb
Overview
Class methods for XML configuration
Instance Method Summary collapse
-
#create_xml_mapping ⇒ Object
Create a new XML mapping instance.
-
#xml(mapping_class = nil, &block) ⇒ Object
XML configuration block.
-
#xml_mapping ⇒ Object?
Get the XML mapping for this class.
Instance Method Details
#create_xml_mapping ⇒ Object
Create a new XML mapping instance
Override in including class to provide specific mapping type. Model classes should return Lutaml::Xml::Mapping.new Type classes should return Lutaml::Model::Type::ValueXmlMapping.new
104 105 106 107 |
# File 'lib/lutaml/xml/configurable.rb', line 104 def create_xml_mapping raise NotImplementedError, "#{self.class} must implement #create_xml_mapping" end |
#xml { ... } ⇒ Object #xml(mapping_class) { ... } ⇒ Object
XML configuration block
Provides unified XML configuration API. The behavior differs between Model and Type classes:
-
Model classes use Lutaml::Xml::Mapping
-
Type classes use Lutaml::Model::Type::ValueXmlMapping
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/lutaml/xml/configurable.rb', line 73 def xml(mapping_class = nil, &block) @xml_mapping ||= create_xml_mapping if mapping_class if mapping_class < Lutaml::Xml::Mapping inherit_mapping_from(mapping_class) elsif mapping_class.is_a?(Class) raise ArgumentError, "#{mapping_class} must be a subclass of Lutaml::Xml::Mapping" end end @xml_mapping.instance_eval(&block) if block @xml_mapping end |
#xml_mapping ⇒ Object?
Get the XML mapping for this class
92 93 94 |
# File 'lib/lutaml/xml/configurable.rb', line 92 def xml_mapping @xml_mapping end |