Class: ActiveInteraction::Errors
- Inherits:
-
ActiveModel::Errors
- Object
- ActiveModel::Errors
- ActiveInteraction::Errors
- Defined in:
- lib/active_interaction/errors.rb,
lib/active_interaction/backports.rb
Overview
An extension that provides symbolic error messages to make introspection
and testing easier.
Instance Attribute Summary collapse
-
#symbolic ⇒ Hash{Symbol => Array<Symbol>}
readonly
Maps attributes to arrays of symbolic messages.
Instance Method Summary collapse
-
#add_sym(attribute, symbol = :invalid, message = nil, options = {}) ⇒ Hash{Symbol => Array<Symbol>}
Adds a symbolic error message to an attribute.
- #clear ⇒ Object
-
#initialize ⇒ Errors
constructor
A new instance of Errors.
-
#merge!(other) ⇒ Errors
Merge other errors into this one.
Constructor Details
Instance Attribute Details
#symbolic ⇒ Hash{Symbol => Array<Symbol>} (readonly)
Maps attributes to arrays of symbolic messages.
98 99 100 |
# File 'lib/active_interaction/errors.rb', line 98 def symbolic @symbolic end |
Instance Method Details
#add_sym(attribute, symbol = :invalid, message = nil, options = {}) ⇒ Hash{Symbol => Array<Symbol>}
Adds a symbolic error message to an attribute.
117 118 119 120 121 |
# File 'lib/active_interaction/errors.rb', line 117 def add_sym(attribute, symbol = :invalid, = nil, = {}) add(attribute, || symbol, ) symbolic[attribute] += [symbol] end |
#clear ⇒ Object
144 145 146 147 148 |
# File 'lib/active_interaction/errors.rb', line 144 def clear symbolic.clear super end |
#merge!(other) ⇒ Errors
Merge other errors into this one.
155 156 157 158 159 |
# File 'lib/active_interaction/errors.rb', line 155 def merge!(other) (other) merge_symbolic!(other) if other.respond_to?(:symbolic) self end |