Class: ServiceRecord::Response
- Inherits:
-
Object
- Object
- ServiceRecord::Response
- Defined in:
- lib/service_record/response.rb
Overview
Response to be returned by a service when it finishes
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Checks for errors.
-
#initialize(result, errors) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
Checks for errors.
Constructor Details
#initialize(result, errors) ⇒ Response
Returns a new instance of Response.
8 9 10 11 |
# File 'lib/service_record/response.rb', line 8 def initialize(result, errors) @result = result @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/service_record/response.rb', line 6 def errors @errors end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/service_record/response.rb', line 6 def result @result end |
Instance Method Details
#failure? ⇒ Boolean
Checks for errors. Returns false if no errors are found, true otherwise.
19 20 21 |
# File 'lib/service_record/response.rb', line 19 def failure? !success? end |
#success? ⇒ Boolean
Checks for errors. Returns true if no errors are found, false otherwise.
14 15 16 |
# File 'lib/service_record/response.rb', line 14 def success? errors.empty? end |