Module: Lutaml::Model::Schema::Definitions::MemberWalk

Defined in:
lib/lutaml/model/schema/definitions/member_walk.rb

Overview

Stateless traversal helpers for the heterogeneous members array of a Definitions::Model. Definitions stay as pure data; the walk logic lives here so consumers (XmlCompiler / RngCompiler dependency collection, future visitors) don't each re-implement the same case-dispatch.

Class Method Summary collapse

Class Method Details

.each_attribute(members, &block) ⇒ Object

Yields every Attribute leaf, recursing into Sequence members and Choice alternatives. Returns an Enumerator when called without a block.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lutaml/model/schema/definitions/member_walk.rb', line 18

def each_attribute(members, &block)
  return enum_for(:each_attribute, members) unless block

  members.each do |member|
    case member
    when Attribute then yield member
    when Sequence  then each_attribute(member.members, &block)
    when Choice    then each_attribute(member.alternatives, &block)
    end
  end
end