Class: SimpleCommandDispatcher::Commands::CommandCallable::Errors

Inherits:
Hash
  • Object
show all
Defined in:
lib/simple_command_dispatcher/commands/errors.rb

Instance Method Summary collapse

Instance Method Details

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



11
12
13
14
15
# File 'lib/simple_command_dispatcher/commands/errors.rb', line 11

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

#add_multiple_errors(errors_hash) ⇒ Object



17
18
19
20
21
# File 'lib/simple_command_dispatcher/commands/errors.rb', line 17

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

#eachObject



23
24
25
26
27
# File 'lib/simple_command_dispatcher/commands/errors.rb', line 23

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

#full_messagesObject



29
30
31
# File 'lib/simple_command_dispatcher/commands/errors.rb', line 29

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