Class: Error
- Inherits:
-
Object
- Object
- Error
- Defined in:
- lib/at_your_service/error.rb
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
4 5 6 7 |
# File 'lib/at_your_service/error.rb', line 4 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.
2 3 4 |
# File 'lib/at_your_service/error.rb', line 2 def errors @errors end |
Instance Method Details
#display ⇒ Object
17 18 19 20 21 22 |
# File 'lib/at_your_service/error.rb', line 17 def display { success: false, errors: @errors } end |
#error_message ⇒ Object
9 10 11 |
# File 'lib/at_your_service/error.rb', line 9 def errors[0] end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/at_your_service/error.rb', line 13 def success? false end |