Class: Decidim::SpamDetection::CommandErrors

Inherits:
Hash
  • Object
show all
Defined in:
lib/decidim/spam_detection/command_errors.rb

Instance Method Summary collapse

Instance Method Details

#add(key, value, _opts = {}) ⇒ Object



6
7
8
9
10
# File 'lib/decidim/spam_detection/command_errors.rb', line 6

def add(key, value, _opts = {})
  self[key] ||= []
  self[key] << value
  self[key].uniq!
end

#add_multiple_errors(errors_hash) ⇒ Object



12
13
14
15
16
# File 'lib/decidim/spam_detection/command_errors.rb', line 12

def add_multiple_errors(errors_hash)
  errors_hash.each do |key, values|
    values.each { |value| add key, value }
  end
end

#eachObject



18
19
20
21
22
# File 'lib/decidim/spam_detection/command_errors.rb', line 18

def each
  each_key do |field|
    self[field].each { |message| yield field, message }
  end
end

#full_messagesObject



24
25
26
# File 'lib/decidim/spam_detection/command_errors.rb', line 24

def full_messages
  map { |attribute, message| full_message(attribute, message) }
end