Class: Lutaml::Xml::Schema::Xsd::Attribute

Inherits:
Base show all
Defined in:
lib/lutaml/xml/schema/xsd/attribute.rb

Constant Summary

Constants inherited from Base

Base::ELEMENT_ORDER_IGNORABLE, Base::XML_DECLARATION_REGEX

Constants included from Model::Serialize

Model::Serialize::DEFAULT_VALUE_MAP, Model::Serialize::INTERNAL_ATTRIBUTES, Model::Serialize::LAZY_EMPTY_COLLECTION

Instance Attribute Summary

Attributes included from Model::Serialize

#lutaml_parent, #lutaml_register, #lutaml_root

Instance Method Summary collapse

Methods inherited from Base

#all?, #annotation?, #any?, #assign_root!, #attribute?, #attribute_group?, #choice?, #complex_content?, #element?, #max_occurrences, #min_occurrences, #resolved_element_order, #sequence?, #simple_content?, #target_prefix, #to_formatted_xml, #unresolvable_items

Methods included from Model::Serialize

#attr_value, #attribute_exist?, #extract_register_id, included, #init_deserialization_state, #initialize, #key_exist?, #key_value, #method_missing, #prepare_instance_format_options, #pretty_print_instance_variables, register_format_mapping_method, register_from_format_method, register_to_format_method, #respond_to_missing?, #to_format, #to_yaml_hash, #using_default?, #using_default_for, #validate_attribute!, #validate_root_mapping!, #value_map, #value_set_for

Methods included from Model::Liquefiable

included, #to_liquid

Methods included from Model::Validation

#format_element_sequences, #order_names, #validate, #validate!, #validate_helper, #validate_sequence!

Methods included from Model::ComparableModel

#already_compared?, #attributes_hash, #calculate_hash, #comparison_key, #eql?, #hash, included, #same_class?

Methods included from Model::Serialize::Builder

#initialize, #mixed_content?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize

Instance Method Details

#cardinalityObject

Translate XSD attribute ‘use` semantics into the cardinality strings expected by Liquid templates.



47
48
49
50
51
52
# File 'lib/lutaml/xml/schema/xsd/attribute.rb', line 47

def cardinality
  case use
  when "required" then "1"
  when "optional" then "0..1"
  end
end

#referenced_nameObject

Resolve the effective attribute name, falling back to the raw ‘ref` when the target cannot be found.



61
62
63
# File 'lib/lutaml/xml/schema/xsd/attribute.rb', line 61

def referenced_name
  referenced_object&.name || ref
end

#referenced_objectObject

Return the attribute itself when it is named, otherwise resolve the root-level attribute referenced by ‘ref`.



67
68
69
70
71
# File 'lib/lutaml/xml/schema/xsd/attribute.rb', line 67

def referenced_object
  return self if name

  find_object(xsd_root.attribute)
end

#referenced_typeObject

Resolve the effective type, following ‘ref` when needed.



55
56
57
# File 'lib/lutaml/xml/schema/xsd/attribute.rb', line 55

def referenced_type
  referenced_object&.type
end