Sha256: 96507c7041aadf81c131284e422b1f2c11f87467ba0257303f2b6e468b0710a5

Contents?: true

Size: 701 Bytes

Versions: 66

Compression:

Stored size: 701 Bytes

Contents

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

    @_visited = true

    if respond_to?(:all_refs)
      all_refs.each do |ref|
        refs[ref.to_s] = 1
      end
    end

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

    @_visited = nil

    refs
  end

  def ref_children
    []
  end
end

# Mixin to Array
class Array
  include RefCheck
  def ref_children
    self
  end
end

# Mixin to Array
class Hash
  include RefCheck
  def ref_children
    values
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
cfndsl-0.16.13 lib/cfndsl/ref_check.rb
cfndsl-0.16.12 lib/cfndsl/ref_check.rb
cfndsl-0.16.11 lib/cfndsl/ref_check.rb
cfndsl-0.16.10 lib/cfndsl/ref_check.rb
cfndsl-0.16.9 lib/cfndsl/ref_check.rb
cfndsl-0.16.8 lib/cfndsl/ref_check.rb
cfndsl-0.16.7 lib/cfndsl/ref_check.rb
cfndsl-0.16.6 lib/cfndsl/ref_check.rb
cfndsl-0.16.5 lib/cfndsl/ref_check.rb
cfndsl-0.16.3 lib/cfndsl/ref_check.rb
cfndsl-0.16.2 lib/cfndsl/ref_check.rb
cfndsl-0.16.1 lib/cfndsl/ref_check.rb
cfndsl-0.15.3 lib/cfndsl/ref_check.rb
cfndsl-0.15.2 lib/cfndsl/ref_check.rb
cfndsl-0.15.1 lib/cfndsl/ref_check.rb
cfndsl-0.15.0 lib/cfndsl/ref_check.rb
cfndsl-0.14.0 lib/cfndsl/ref_check.rb
cfndsl-0.13.1 lib/cfndsl/ref_check.rb
cfndsl-0.13.0 lib/cfndsl/ref_check.rb
cfndsl-0.12.11 lib/cfndsl/ref_check.rb