Class: Mutations::ErrorHash
- Inherits:
-
Hash
- Object
- Hash
- Mutations::ErrorHash
- Defined in:
- lib/mutations/errors.rb
Overview
mutation.errors is an ErrorHash instance like this: { email: ErrorAtom(:matches), name: ErrorAtom(:too_weird, message: "is too weird"), adddress: { # Nested ErrorHash object city: ErrorAtom(:not_found, message: "That's not a city, silly!"), state: ErrorAtom(:in) } }
Instance Method Summary collapse
-
#message ⇒ Object
Returns a nested HashWithIndifferentAccess where the values are messages.
-
#message_list ⇒ Object
Returns a flat array where each element is a full sentence.
-
#symbolic ⇒ Object
Returns a nested HashWithIndifferentAccess where the values are symbols.
Instance Method Details
#message ⇒ Object
Returns a nested HashWithIndifferentAccess where the values are messages. Eg: { email: "isn't in the right format", name: "is too weird", adddress: { city: "is not a city", state: "isn't a valid option" } }
133 134 135 136 137 138 139 |
# File 'lib/mutations/errors.rb', line 133 def HashWithIndifferentAccess.new.tap do |hash| each do |k, v| hash[k] = v. end end end |
#message_list ⇒ Object
Returns a flat array where each element is a full sentence. Eg: [ "Email isn't in the right format.", "Name is too weird", "That's not a city, silly!", "State isn't a valid option." ]
148 149 150 151 152 153 154 |
# File 'lib/mutations/errors.rb', line 148 def list = [] each do |k, v| list.concat(v.) end list end |
#symbolic ⇒ Object
Returns a nested HashWithIndifferentAccess where the values are symbols. Eg: { email: :matches, name: :too_weird, adddress: { city: :not_found, state: :in } }
116 117 118 119 120 121 122 |
# File 'lib/mutations/errors.rb', line 116 def symbolic HashWithIndifferentAccess.new.tap do |hash| each do |k, v| hash[k] = v.symbolic end end end |