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

Instance Method Details

#add(attribute, message = :invalid, options = {}) ⇒ Object


24
25
26
27
# File 'lib/adequate_errors/interceptor.rb', line 24

def add(attribute, message = :invalid, options = {})
  super
  @adequate_errors.add(attribute, message, options)
end

#adequateObject

Accessor


30
31
32
# File 'lib/adequate_errors/interceptor.rb', line 30

def adequate
  @adequate_errors
end

#clearObject


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