Class: Lutaml::Xml::Schema::Xsd::Group

Inherits:
Base show all
Defined in:
lib/lutaml/xml/schema/xsd/group.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

#child_elements(array = []) ⇒ Object

Walk the referenced group definition and collect its element children recursively.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/lutaml/xml/schema/xsd/group.rb', line 40

def child_elements(array = [])
  group = referenced_object
  return array unless group

  group.resolved_element_order&.each do |child|
    if child.is_a?(Element)
      array << child
    elsif child.respond_to?(:child_elements)
      child.child_elements(array)
    end
  end
  array
end

#find_elements_used(element_name) ⇒ Object

Check whether the group references a given element name anywhere in its nested content model.



56
57
58
59
60
61
62
63
64
# File 'lib/lutaml/xml/schema/xsd/group.rb', line 56

def find_elements_used(element_name)
  resolved_element_order&.any? do |child|
    if child.is_a?(Element)
      reference_matches?(element_name, child.ref || child.name)
    elsif child.respond_to?(:find_elements_used)
      child.find_elements_used(element_name)
    end
  end || false
end

#referenced_objectObject

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



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

def referenced_object
  return self if name

  find_object(xsd_root.group)
end