Sha256: 4ebbd0ad142f81c4878c523f5e1f68286ab028a204f628fc6a67562bec8efec3
Contents?: true
Size: 1022 Bytes
Versions: 22
Compression:
Stored size: 1022 Bytes
Contents
# FIXME: This module should be updated when a newer version of RGen (>0.6.2) adds required meta model "e-method" supports. # module Puppet::Pops::Containment # Returns Enumerable, thus allowing # some_element.eAllContents each {|contained| } # This is a depth first enumeration where parent appears before children. # @note the top-most object itself is not included in the enumeration, only what it contains. def eAllContents EAllContentsEnumerator.new(self) end class EAllContentsEnumerator include Enumerable def initialize o @element = o end def each &block if block_given? eAllContents(@element, &block) @element else self end end def eAllContents(element, &block) element.class.ecore.eAllReferences.select{|r| r.containment}.each do |r| children = element.getGenericAsArray(r.name) children.each do |c| block.call(c) eAllContents(c, &block) end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems