class ChefAPI::ErrorCollection

Private internal class for managing the error collection.

Public Class Methods

new() click to toggle source

The default proc for the hash needs to be an empty Array.

@return [Proc]

Calls superclass method
# File lib/chef-api/error_collection.rb, line 11
def initialize
  super { |h, k| h[k] = [] }
end

Public Instance Methods

add(key, error) click to toggle source

Add a new error to the hash.

@param [Symbol] key

the attribute key

@param [String] error

the error message to push

@return [self]

# File lib/chef-api/error_collection.rb, line 25
def add(key, error)
  self[key].push(error)
  self
end
full_messages() click to toggle source

Output the full messages for each error. This is useful for displaying information about validation to the user when something goes wrong.

@return [Array<String>]

# File lib/chef-api/error_collection.rb, line 36
def full_messages
  map do |key, errors|
    errors.map do |error|
      "`#{key}' #{error}"
    end
  end.flatten
end