Class: Lutaml::Xml::Schema::Xsd::AttributeGroup
- Inherits:
-
Base
- Object
- Model::Serializable
- Base
- Lutaml::Xml::Schema::Xsd::AttributeGroup
- Defined in:
- lib/lutaml/xml/schema/xsd/attribute_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
-
#attribute_elements(array = []) ⇒ Object
Flatten nested attribute-group references into a single list of attribute objects for template consumption.
-
#find_used_by(object) ⇒ Object
Recursively inspect nested content to determine whether the given object references this attribute group.
-
#referenced_object ⇒ Object
Return the attribute group itself when it is named, otherwise resolve the root-level group referenced by ‘ref`.
-
#used_by ⇒ Object
Return complex types that reference this attribute group.
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
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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize
Instance Method Details
#attribute_elements(array = []) ⇒ Object
Flatten nested attribute-group references into a single list of attribute objects for template consumption.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lutaml/xml/schema/xsd/attribute_group.rb', line 45 def attribute_elements(array = []) group = referenced_object return array unless group group.resolved_element_order&.each do |child| case child when AttributeGroup if child.referenced_object child.attribute_elements(array) else array << child end when Attribute array << child end end array end |
#find_used_by(object) ⇒ Object
Recursively inspect nested content to determine whether the given object references this attribute group.
66 67 68 69 70 71 72 73 74 |
# File 'lib/lutaml/xml/schema/xsd/attribute_group.rb', line 66 def find_used_by(object) object&.resolved_element_order&.any? do |child| if child.is_a?(AttributeGroup) child.ref == name else find_used_by(child) end end || false end |
#referenced_object ⇒ Object
Return the attribute group itself when it is named, otherwise resolve the root-level group referenced by ‘ref`.
78 79 80 81 82 |
# File 'lib/lutaml/xml/schema/xsd/attribute_group.rb', line 78 def referenced_object return self if name find_object(xsd_root.attribute_group) end |
#used_by ⇒ Object
Return complex types that reference this attribute group.
39 40 41 |
# File 'lib/lutaml/xml/schema/xsd/attribute_group.rb', line 39 def used_by xsd_root.complex_type.select { |type| find_used_by(type) } end |