Class: Error
- Inherits:
-
Object
- Object
- Error
- Defined in:
- app/services/error.rb
Overview
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #display ⇒ Object
- #error_message ⇒ Object
-
#initialize(errors = nil) ⇒ Error
constructor
Pass 1 string or array of strings.
- #success? ⇒ Boolean
Constructor Details
#initialize(errors = nil) ⇒ Error
Pass 1 string or array of strings
5 6 7 8 |
# File 'app/services/error.rb', line 5 def initialize(errors = nil) errors = [] unless errors @errors = [errors].flatten # handle array or string end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'app/services/error.rb', line 3 def errors @errors end |
Instance Method Details
#display ⇒ Object
18 19 20 21 22 23 |
# File 'app/services/error.rb', line 18 def display return { success: false, errors: @errors } end |
#error_message ⇒ Object
10 11 12 |
# File 'app/services/error.rb', line 10 def error[0] end |
#success? ⇒ Boolean
14 15 16 |
# File 'app/services/error.rb', line 14 def success? false end |