Module: AdequateErrors::Interceptor
- Defined in:
- lib/adequate_errors/interceptor.rb
Overview
Wraps around Rails’ errors object, intercepting its state changes in order to update AdequateErrors’ errors object.
Instance Method Summary collapse
- #add(attribute, message = :invalid, options = {}) ⇒ Object
-
#adequate ⇒ Object
Accessor.
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #initialize(base) ⇒ Object
Instance Method Details
#add(attribute, message = :invalid, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/adequate_errors/interceptor.rb', line 24 def add(attribute, = :invalid, = {}) = .dup = super if .has_key?(:message) && ![:message].is_a?(Symbol) [:message] = (attribute, .last) end = if !.is_a?(Symbol) (attribute, .last) else end @adequate_errors.add(attribute, , ) end |
#adequate ⇒ Object
Accessor
43 44 45 |
# File 'lib/adequate_errors/interceptor.rb', line 43 def adequate @adequate_errors end |
#clear ⇒ Object
14 15 16 17 |
# File 'lib/adequate_errors/interceptor.rb', line 14 def clear super @adequate_errors.clear end |
#delete(key) ⇒ Object
19 20 21 22 |
# File 'lib/adequate_errors/interceptor.rb', line 19 def delete(key) super @adequate_errors.delete(key) end |
#initialize(base) ⇒ Object
8 9 10 11 12 |
# File 'lib/adequate_errors/interceptor.rb', line 8 def initialize(base) rails_errors = super @adequate_errors = ::AdequateErrors::Errors.new(base) rails_errors end |