Sha256: daacfcf27f69a673b342de138f60089cacf565e2a72a6292a0d20aeadb4e5321

Contents?: true

Size: 758 Bytes

Versions: 52

Compression:

Stored size: 758 Bytes

Contents

module RefCheck
  ##
  # This module defines some methods for walking the reference tree
  # of various objects.
  #
  def references(refs)
    ##
    # Build up a set of references.
    #
    raise "Circular reference" if @_visited

    @_visited = true
    
    if( self.respond_to?(:get_references ) ) then
      self.get_references.each do |ref|
        refs[ref.to_s] = 1
      end
    end

    self.ref_children.each do |elem|
      elem.references(refs) if elem.respond_to?(:references)
    end

    @_visited = nil

    return refs
  end

  def ref_children
    return []
  end

end

class Array
  include RefCheck
  def ref_children
    return self
  end
end

class Hash
  include RefCheck
  def ref_children
    return self.values
  end
end      

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
cfndsl-0.4.4 lib/cfndsl/RefCheck.rb
cfndsl-0.4.3 lib/cfndsl/RefCheck.rb
cfndsl-0.4.2 lib/cfndsl/RefCheck.rb
cfndsl-0.4.1 lib/cfndsl/RefCheck.rb
cfndsl-0.4.0 lib/cfndsl/RefCheck.rb
cfndsl-0.3.6 lib/cfndsl/RefCheck.rb
cfndsl-0.3.5 lib/cfndsl/RefCheck.rb
cfndsl-0.3.4 lib/cfndsl/RefCheck.rb
cfndsl-0.3.3 lib/cfndsl/RefCheck.rb
cfndsl-0.3.2 lib/cfndsl/RefCheck.rb
cfndsl-0.3.1 lib/cfndsl/RefCheck.rb
cfndsl-0.2.9 lib/cfndsl/RefCheck.rb
cfndsl-0.2.8 lib/cfndsl/RefCheck.rb
cfndsl-0.3.0 lib/cfndsl/RefCheck.rb
cfndsl-0.2.7 lib/cfndsl/RefCheck.rb
cfndsl-0.2.4 lib/cfndsl/RefCheck.rb
cfndsl-0.2.3 lib/cfndsl/RefCheck.rb
cfndsl-0.2.2 lib/cfndsl/RefCheck.rb
cfndsl-0.2.1 lib/cfndsl/RefCheck.rb
cfndsl-0.2.0 lib/cfndsl/RefCheck.rb