Class: Servus::Support::Response
- Inherits:
-
Object
- Object
- Servus::Support::Response
- Defined in:
- lib/servus/support/response.rb
Overview
Encapsulates the result of a service execution.
Response objects are returned by all service calls and contain either successful data or an error, never both. Use #success? to determine which path to take when handling results.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
[Object] The data returned by the service.
-
#error ⇒ Object
readonly
[Servus::Support::Errors::ServiceError] The error returned by the service.
Instance Method Summary collapse
-
#initialize(success, data, error) ⇒ Response
constructor
private
Creates a new response object.
-
#success? ⇒ Boolean
Checks if the service execution was successful.
Constructor Details
#initialize(success, data, error) ⇒ Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is typically called by Base#success or Base#failure rather than being instantiated directly.
Creates a new response object.
52 53 54 55 56 |
# File 'lib/servus/support/response.rb', line 52 def initialize(success, data, error) @success = success @data = data @error = error end |
Instance Attribute Details
#data ⇒ Object (readonly)
[Object] The data returned by the service
37 38 39 |
# File 'lib/servus/support/response.rb', line 37 def data @data end |
#error ⇒ Object (readonly)
[Servus::Support::Errors::ServiceError] The error returned by the service
40 41 42 |
# File 'lib/servus/support/response.rb', line 40 def error @error end |
Instance Method Details
#success? ⇒ Boolean
Checks if the service execution was successful.
69 70 71 |
# File 'lib/servus/support/response.rb', line 69 def success? @success end |