Module: RefCheck

Included in:
Array, CfnDsl::JSONable, Hash
Defined in:
lib/cfndsl/ref_check.rb

Overview

This module defines some methods for walking the reference tree of various objects.

Defined Under Namespace

Classes: NullReference, SelfReference

Instance Method Summary collapse

Instance Method Details

#build_references(refs = [], origin = nil, method = :all_refs) ⇒ Object

Build up a set of references. rubocop:disable Metrics/CyclomaticComplexity



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cfndsl/ref_check.rb', line 14

def build_references(refs = [], origin = nil, method = :all_refs)
  if respond_to?(method)
    send(method).each do |ref|
      raise SelfReference, "#{origin} references itself at #{to_json}" if origin && ref.to_s == origin
      raise NullReference, "#{origin} contains null value reference at #{to_json}" if origin && ref.nil?

      refs << ref
    end
  end

  ref_children.each do |elem|
    # Nulls are not permitted in Cloudformation templates.
    raise NullReference, "#{origin} contains null value reference at #{to_json}" if origin && elem.nil?

    elem.build_references(refs, origin, method) if elem.respond_to?(:build_references)
  end

  refs
end

#ref_childrenObject

rubocop:enable Metrics/CyclomaticComplexity



35
36
37
# File 'lib/cfndsl/ref_check.rb', line 35

def ref_children
  []
end