def valid_ref?(ref, origin = nil)
      ref = ref.to_s
      origin = origin.to_s if origin

      return true if GLOBAL_REFS.key?(ref)

      return true if @Parameters && @Parameters.key?(ref)

      return !origin || !@_resource_refs || !@_resource_refs[ref] || !@_resource_refs[ref].key?(origin) if @Resources.key?(ref)

      false
    end
def valid_ref?(ref, origin = nil)
      ref = ref.to_s
      origin = origin.to_s if origin

      return true if GLOBAL_REFS.key?(ref)

      return true if @Parameters && @Parameters.key?(ref)

      return !origin || !@_resource_refs || !@_resource_refs[ref] || !@_resource_refs[ref].key?(origin) if @Resources.key?(ref)

      false
    end
rubocop:disable Metrics/PerceivedComplexity