Class: EventHookClientServer::Client::Response
- Inherits:
-
Object
- Object
- EventHookClientServer::Client::Response
- Defined in:
- lib/event_hook_client_server/client/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#pagination ⇒ Object
readonly
Returns the value of attribute pagination.
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean (also: #failure?, #error?)
-
#initialize(data: nil, pagination: nil, errors: nil, failure: false) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean (also: #succeeded?, #ok?)
Constructor Details
#initialize(data: nil, pagination: nil, errors: nil, failure: false) ⇒ Response
Returns a new instance of Response.
18 19 20 21 22 23 24 |
# File 'lib/event_hook_client_server/client/response.rb', line 18 def initialize(data: nil, pagination: nil, errors: nil, failure: false) @data = data @pagination = pagination @errors = errors @failure = failure freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/event_hook_client_server/client/response.rb', line 14 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
16 17 18 |
# File 'lib/event_hook_client_server/client/response.rb', line 16 def errors @errors end |
#pagination ⇒ Object (readonly)
Returns the value of attribute pagination.
15 16 17 |
# File 'lib/event_hook_client_server/client/response.rb', line 15 def pagination @pagination end |
Class Method Details
.fail!(errors) ⇒ Object
10 11 12 |
# File 'lib/event_hook_client_server/client/response.rb', line 10 def self.fail!(errors) new(errors: Array(errors), failure: true) end |
.success!(data: nil, pagination: nil) ⇒ Object
6 7 8 |
# File 'lib/event_hook_client_server/client/response.rb', line 6 def self.success!(data: nil, pagination: nil) new(data: data, pagination: pagination) end |
Instance Method Details
#failed? ⇒ Boolean Also known as: failure?, error?
26 27 28 |
# File 'lib/event_hook_client_server/client/response.rb', line 26 def failed? failure == true end |
#success? ⇒ Boolean Also known as: succeeded?, ok?
32 33 34 |
# File 'lib/event_hook_client_server/client/response.rb', line 32 def success? !failed? end |