Class: Kharon::Handlers::Messages
- Inherits:
-
Object
- Object
- Kharon::Handlers::Messages
- Defined in:
- lib/kharon/handlers/messages.rb
Overview
Errors handler that stores each problem encountered during validation.
Instance Method Summary collapse
-
#errors ⇒ Array
Getter for the errors, cloning it so no error can be added from outside of the report_error method.
-
#initialize ⇒ Messages
constructor
Constructor of the class, initializing the errors array.
-
#report_error(error_hash) ⇒ Kharon::Handlers::Messages
Method used to report an error by storing it in an array.
Constructor Details
#initialize ⇒ Messages
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
#errors ⇒ Array
Getter for the errors, cloning it so no error can be added from outside of the report_error method
23 24 25 |
# File 'lib/kharon/handlers/messages.rb', line 23 def errors @errors.clone end |
#report_error(error_hash) ⇒ Kharon::Handlers::Messages
Method used to report an error by storing it in an array.
16 17 18 19 |
# File 'lib/kharon/handlers/messages.rb', line 16 def report_error(error_hash) @errors.push(error_hash) self end |