Class: Kharon::Handlers::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/kharon/handlers/messages.rb

Overview

Errors handler that stores each problem encountered during validation.

Author:

Instance Method Summary (collapse)

Constructor Details

- (Messages) initialize

Constructor of the class, initializing the errors array.



9
10
11
# File 'lib/kharon/handlers/messages.rb', line 9

def initialize
  @errors = Array.new
end

Instance Method Details

- (Array) errors

Getter for the errors, cloning it so no error can be added from outside of the report_error method

Returns:

  • (Array)

    the array of errors.



23
24
25
# File 'lib/kharon/handlers/messages.rb', line 23

def errors
  @errors.clone
end

- (Kharon::Handlers::Messages) report_error(error_hash)

Method used to report an error by storing it in an array.

Parameters:

  • error_hash (Hash)

    a Hash describing the error.

Returns:



16
17
18
19
# File 'lib/kharon/handlers/messages.rb', line 16

def report_error(error_hash)
  @errors.push(error_hash)
  self
end