Class: Lev::Errors
Overview
A collection of Error objects.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add(fail, args = {}) ⇒ Object
-
#has_offending_input?(input) ⇒ Boolean
Checks to see if the provided input is associated with one of the errors.
- #ignore(arg) ⇒ Object
Instance Method Details
#[](key) ⇒ Object
25 26 27 |
# File 'lib/lev/errors.rb', line 25 def [](key) self[key] end |
#add(fail, args = {}) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/lev/errors.rb', line 7 def add(fail, args={}) args[:kind] ||= :lev error = Error.new(args) return if ignored_error_procs.any?{|proc| proc.call(error)} self.push(error) throw :fatal_errors_encountered if fail end |
#has_offending_input?(input) ⇒ Boolean
Checks to see if the provided input is associated with one of the errors.
30 31 32 |
# File 'lib/lev/errors.rb', line 30 def has_offending_input?(input) self.any? {|error| [error.offending_inputs].flatten.include? input} end |
#ignore(arg) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/lev/errors.rb', line 15 def ignore(arg) proc = arg.is_a?(Symbol) ? Proc.new{|error| error.code == arg} : arg raise IllegalArgument if !proc.respond_to?(:call) ignored_error_procs.push(proc) end |