Sha256: 00f33824d29fa6df4c3472e74a4ce2bb13a94626749ec865f8566f0305d68cee
Contents?: true
Size: 731 Bytes
Versions: 1
Compression:
Stored size: 731 Bytes
Contents
# frozen_string_literal: true module KDoc # Guarded provides parameter waring and guarding # # TODO: this could be moved into KType or KGuard module Guarded Guard = Struct.new(:type, :message) def guard(message) errors << Guard.new(:guard, message) end def warn(message) errors << Guard.new(:warning, message) end alias warning warn def errors @errors ||= [] end def error_messages errors.map(&:message) end def valid? errors.length.zero? end def log_any_messages errors.each do |error| log.warn error.message if error.type == :warning log.error error.message if error.type == :guard end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
k_doc-0.0.22 | lib/k_doc/mixins/guarded.rb |