Class: GitPunch::ClientErrors
- Inherits:
-
Object
- Object
- GitPunch::ClientErrors
- Includes:
- Enumerable
- Defined in:
- lib/git_punch/client_errors.rb
Instance Method Summary collapse
- #<<(hash_of_arrays) ⇒ Object
- #add(attribute, message) ⇒ Object
- #any? ⇒ Boolean
- #attributes ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ ClientErrors
constructor
A new instance of ClientErrors.
- #messages ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ ClientErrors
Returns a new instance of ClientErrors.
5 6 7 |
# File 'lib/git_punch/client_errors.rb', line 5 def initialize @collection = Hash.new end |
Instance Method Details
#<<(hash_of_arrays) ⇒ Object
23 24 25 |
# File 'lib/git_punch/client_errors.rb', line 23 def << hash_of_arrays collection.merge hash_of_arrays end |
#add(attribute, message) ⇒ Object
17 18 19 20 21 |
# File 'lib/git_punch/client_errors.rb', line 17 def add attribute, collection[attribute] ||= Array.new collection[attribute].push end |
#any? ⇒ Boolean
27 28 29 |
# File 'lib/git_punch/client_errors.rb', line 27 def any? collection.any? end |
#attributes ⇒ Object
39 40 41 |
# File 'lib/git_punch/client_errors.rb', line 39 def attributes collection.keys.uniq end |
#each ⇒ Object
9 10 11 |
# File 'lib/git_punch/client_errors.rb', line 9 def each collection.each { |item| yield item } end |
#messages ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/git_punch/client_errors.rb', line 31 def reduce([]) do |, (attribute,)| << .reduce([]) do |all,| all << "#{attribute} #{message}" end end end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/git_punch/client_errors.rb', line 13 def to_s combined.join ', ' end |