Class: ChefAPI::ErrorCollection
- Inherits:
-
Hash
- Object
- Hash
- ChefAPI::ErrorCollection
- Defined in:
- lib/chef-api/error_collection.rb
Overview
Private internal class for managing the error collection.
Instance Method Summary collapse
-
#add(key, error) ⇒ self
Add a new error to the hash.
-
#full_messages ⇒ Array<String>
Output the full messages for each error.
-
#initialize ⇒ Proc
constructor
The default proc for the hash needs to be an empty Array.
Constructor Details
#initialize ⇒ Proc
The default proc for the hash needs to be an empty Array.
11 12 13 |
# File 'lib/chef-api/error_collection.rb', line 11 def initialize super { |h, k| h[k] = [] } end |
Instance Method Details
#add(key, error) ⇒ self
Add a new error to the hash.
25 26 27 28 |
# File 'lib/chef-api/error_collection.rb', line 25 def add(key, error) self[key].push(error) self end |
#full_messages ⇒ Array<String>
Output the full messages for each error. This is useful for displaying information about validation to the user when something goes wrong.
36 37 38 39 40 41 42 |
# File 'lib/chef-api/error_collection.rb', line 36 def self.map do |key, errors| errors.map do |error| "`#{key}' #{error}" end end.flatten end |