Class: GitPunch::ClientErrors

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/git_punch/client_errors.rb

Instance Method Summary collapse

Constructor Details

#initializeClientErrors

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, message
  collection[attribute] ||= Array.new

  collection[attribute].push message
end

#any?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/git_punch/client_errors.rb', line 27

def any?
  collection.any?
end

#attributesObject



39
40
41
# File 'lib/git_punch/client_errors.rb', line 39

def attributes
  collection.keys.uniq
end

#eachObject



9
10
11
# File 'lib/git_punch/client_errors.rb', line 9

def each
  collection.each { |item| yield item }
end

#messagesObject



31
32
33
34
35
36
37
# File 'lib/git_punch/client_errors.rb', line 31

def messages
  reduce([]) do |error_messages, (attribute,messages)|
    error_messages << messages.reduce([]) do |all,message|
      all << "#{attribute} #{message}"
    end
  end
end

#to_sObject



13
14
15
# File 'lib/git_punch/client_errors.rb', line 13

def to_s
  combined.join ', '
end