class Puppet::Pops::Containment::EAllContentsEnumerator

Public Instance Methods

eAllContents(element) { |c| ... } click to toggle source
# File lib/puppet/pops/containment.rb, line 58
def eAllContents(element, &block)
  # This method is performance critical and code has been manually in-lined.
  # Resist the urge to make this pretty.
  # The slow way is element.eAllContainments.each {|c| element.getGenericsAsArray(c.name) }
  #
  (@@cache[element.class] || all_containment_getters(element)).each do |r|
    children = element.send(r)
    if children.is_a?(Array)
      children.each do |c|
        yield c
        eAllContents(c, &block)
      end
    elsif !children.nil?
      yield children
      eAllContents(children, &block)
    end
  end
end
each(&block) click to toggle source
# File lib/puppet/pops/containment.rb, line 49
def each &block
  if block_given?
    eAllContents(@element, &block)
    @element
  else
    self
  end
end

Public Class Methods

new(o) click to toggle source
# File lib/puppet/pops/containment.rb, line 44
def initialize o
  @element = o
  @@cache ||= {}
end