Module: Lite::Service::Errors
- Defined in:
- lib/lite/service/errors.rb
Instance Method Summary collapse
- #errored? ⇒ Boolean
- #errors ⇒ Object
- #fail! ⇒ Object
- #failure? ⇒ Boolean
- #result! ⇒ Object
- #success? ⇒ Boolean
- #validate! ⇒ Object (also: #valid?)
Instance Method Details
#errored? ⇒ Boolean
13 14 15 |
# File 'lib/lite/service/errors.rb', line 13 def errored? !errors.empty? end |
#errors ⇒ Object
9 10 11 |
# File 'lib/lite/service/errors.rb', line 9 def errors @errors ||= Lite::Errors::Messages.new end |
#fail! ⇒ Object
17 18 19 |
# File 'lib/lite/service/errors.rb', line 17 def fail! raise Lite::Service::ValidationError end |
#failure? ⇒ Boolean
21 22 23 |
# File 'lib/lite/service/errors.rb', line 21 def failure? called? && errored? end |
#result! ⇒ Object
25 26 27 |
# File 'lib/lite/service/errors.rb', line 25 def result! result if valid? end |
#success? ⇒ Boolean
29 30 31 |
# File 'lib/lite/service/errors.rb', line 29 def success? called? && !errored? end |
#validate! ⇒ Object Also known as: valid?
33 34 35 36 37 |
# File 'lib/lite/service/errors.rb', line 33 def validate! return true if success? fail! end |