Module: ExternalErrors

Defined in:
lib/external_errors.rb

Defined Under Namespace

Classes: ExternalErrorStore

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



27
28
29
# File 'lib/external_errors.rb', line 27

def self.included(base)
  base.class_eval { validate :check_for_external_errors }
end

Instance Method Details

#add_external_error(error) ⇒ Object



31
32
33
# File 'lib/external_errors.rb', line 31

def add_external_error(error)
  external_errors << error
end

#add_external_error_to_errors(error) ⇒ Object



44
45
46
# File 'lib/external_errors.rb', line 44

def add_external_error_to_errors(error)
  errors.add(:base, error)
end

#add_external_errors(errors) ⇒ Object



35
36
37
# File 'lib/external_errors.rb', line 35

def add_external_errors(errors)
  errors.each { |error| add_external_error error }
end

#external_errorsObject



39
40
41
42
# File 'lib/external_errors.rb', line 39

def external_errors
  error_added_cb = proc { |error| add_external_error_to_errors error }
  @external_errors ||= ExternalErrorStore.new error_added_cb
end