class Kharon::Handlers::Messages

Errors handler that stores each problem encountered during validation. @author Vincent Courtois <courtois.vincent@outlook.com>

Public Class Methods

new() click to toggle source

Constructor of the class, initializing the errors array.

# File lib/kharon/handlers/messages.rb, line 9
def initialize
  @errors = Array.new
end

Public Instance Methods

errors() click to toggle source

Getter for the errors, cloning it so no error can be added from outside of the report_error method @return [Array] the array of errors.

# File lib/kharon/handlers/messages.rb, line 23
def errors
  @errors.clone
end
report_error(error_hash) click to toggle source

Method used to report an error by storing it in an array. @param [Hash] error_hash a Hash describing the error. @return [Kharon::Handlers::Messages] the errors handler after insertion, so several calls can be chained.

# File lib/kharon/handlers/messages.rb, line 16
def report_error(error_hash)
  @errors.push(error_hash)
  self
end