Module: Xmi::XmiIdentity

Defined in:
lib/xmi/xmi_identity.rb

Overview

Shared XMI identity attributes and their XML mappings.

Many XMI elements share the same set of identity attributes: id, label, uuid, href, idref, type. This module centralizes their declarations to prevent divergence bugs (e.g., issue #74 where idref was declared as :string instead of ::Xmi::Type::XmiIdRef).

Examples:

class MyElement < Lutaml::Model::Serializable
  include Xmi::XmiIdentity::Attributes

  xml do
    Xmi::XmiIdentity.apply_xml_mappings(self)
  end
end

Defined Under Namespace

Modules: Attributes

Class Method Summary collapse

Class Method Details

.apply_xml_mappings(mapping) ⇒ Object

Apply XMI identity XML attribute mappings to a mapping builder. Call this inside an ‘xml do … end` block.

Parameters:

  • mapping (Lutaml::Xml::Mapping)

    the mapping builder (self in xml block)



37
38
39
40
41
42
43
44
# File 'lib/xmi/xmi_identity.rb', line 37

def self.apply_xml_mappings(mapping)
  mapping.map_attribute "id", to: :id
  mapping.map_attribute "label", to: :label
  mapping.map_attribute "uuid", to: :uuid
  mapping.map_attribute "href", to: :href
  mapping.map_attribute "idref", to: :idref
  mapping.map_attribute "type", to: :type
end