Class: SimpleCommand::Errors
- Inherits:
-
Hash
- Object
- Hash
- SimpleCommand::Errors
- Defined in:
- lib/simple_command/errors.rb
Instance Method Summary collapse
- #add(key, value, _opts = {}) ⇒ Object
- #add_multiple_errors(errors_hash) ⇒ Object
- #each ⇒ Object
- #full_messages ⇒ Object
Instance Method Details
#add(key, value, _opts = {}) ⇒ Object
5 6 7 8 9 |
# File 'lib/simple_command/errors.rb', line 5 def add(key, value, _opts = {}) self[key] ||= [] self[key] << value self[key].uniq! end |
#add_multiple_errors(errors_hash) ⇒ Object
11 12 13 14 15 |
# File 'lib/simple_command/errors.rb', line 11 def add_multiple_errors(errors_hash) errors_hash.each do |key, values| SimpleCommand::Utils.array_wrap(values).each { |value| add key, value } end end |
#each ⇒ Object
17 18 19 20 21 |
# File 'lib/simple_command/errors.rb', line 17 def each each_key do |field| self[field].each { || yield field, } end end |
#full_messages ⇒ Object
23 24 25 |
# File 'lib/simple_command/errors.rb', line 23 def map { |attribute, | (attribute, ) } end |