Sha256: eb86428b0e92dab7f484f15e71540cdc204cb7970d54fbbf5e8c9fcdb058457e
Contents?: true
Size: 903 Bytes
Versions: 49
Compression:
Stored size: 903 Bytes
Contents
# frozen_string_literal: true module ErpIntegration module Resources # The `ErpIntegration::Resources::Errors` expose a clean, simple API to manage # and display error messages for any `ErpIntegration::Resource` instance. class Errors include Enumerable extend Forwardable def_delegators :@errors, :any?, :blank?, :clear, :count, :empty?, :uniq!, :size def initialize @errors = [] end # Allows adding new error messages to the `ErpIntegration::Resource`. # @param message [String] An (internal/external) error message. # @return [String] The given error message. def add(message) raise ErpIntegration::Error, 'Use a simple string as an error message' unless message.is_a?(String) @errors << message message end def each(&block) @errors.each(&block) end end end end
Version data entries
49 entries across 49 versions & 1 rubygems