Sha256: 500b7223fa8381665d079140f90dd1227809dc50689d894b603f2225f0a026b0
Contents?: true
Size: 1.23 KB
Versions: 14
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true # This module defines some methods for walking the reference tree # of various objects. module RefCheck class SelfReference < StandardError end class NullReference < StandardError end # Build up a set of references. # rubocop:disable Metrics/CyclomaticComplexity 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 # rubocop:enable Metrics/CyclomaticComplexity def ref_children [] end end # Mixin to Array class Array include RefCheck def ref_children self end end # Mixin to Hash class Hash include RefCheck def ref_children values end end
Version data entries
14 entries across 14 versions & 1 rubygems