Class: MusicTodayApiWrapper::RestClients::CommonResponse
- Inherits:
-
Object
- Object
- MusicTodayApiWrapper::RestClients::CommonResponse
- Defined in:
- lib/rest_clients/common_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(data = {}, errors = []) ⇒ CommonResponse
constructor
A new instance of CommonResponse.
- #success? ⇒ Boolean
- #work ⇒ Object
Constructor Details
#initialize(data = {}, errors = []) ⇒ CommonResponse
Returns a new instance of CommonResponse.
6 7 8 9 |
# File 'lib/rest_clients/common_response.rb', line 6 def initialize(data = {}, errors = []) @data = data @errors = errors end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/rest_clients/common_response.rb', line 4 def data @data end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/rest_clients/common_response.rb', line 4 def errors @errors end |
Instance Method Details
#success? ⇒ Boolean
19 20 21 |
# File 'lib/rest_clients/common_response.rb', line 19 def success? @errors.empty? end |
#work ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/rest_clients/common_response.rb', line 11 def work yield self rescue StandardError => error @errors.push(error.) self end |