Class: Protons8::ProtonCouch::CouchResponse::BaseResponse
- Inherits:
-
Object
- Object
- Protons8::ProtonCouch::CouchResponse::BaseResponse
- Defined in:
- lib/protoncouch.rb
Overview
Add several methods to all type of response
Direct Known Subclasses
Instance Method Summary collapse
- #attachment(id) ⇒ Object
- #attachments ⇒ Object
- #conflict? ⇒ Boolean
- #error? ⇒ Boolean
- #error_name ⇒ Object
-
#initialize(hash) ⇒ BaseResponse
constructor
A new instance of BaseResponse.
- #no_error? ⇒ Boolean
- #not_found? ⇒ Boolean
- #raw ⇒ Object
- #reason ⇒ Object
- #unauth? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ BaseResponse
Returns a new instance of BaseResponse.
98 99 100 |
# File 'lib/protoncouch.rb', line 98 def initialize(hash) @hash = hash end |
Instance Method Details
#attachment(id) ⇒ Object
138 139 140 |
# File 'lib/protoncouch.rb', line 138 def (id) @hash['_attachments'] ? @hash['_attachments'][id] : nil end |
#attachments ⇒ Object
134 135 136 |
# File 'lib/protoncouch.rb', line 134 def @hash['_attachments'] || nil end |
#conflict? ⇒ Boolean
126 127 128 |
# File 'lib/protoncouch.rb', line 126 def conflict? @hash['error'] == 'conflict' ? true : false end |
#error? ⇒ Boolean
102 103 104 |
# File 'lib/protoncouch.rb', line 102 def error? not @hash['error'].nil? end |
#error_name ⇒ Object
110 111 112 |
# File 'lib/protoncouch.rb', line 110 def error_name @hash['error'] || 'No error' end |
#no_error? ⇒ Boolean
106 107 108 |
# File 'lib/protoncouch.rb', line 106 def no_error? @hash['error'].nil? end |
#not_found? ⇒ Boolean
118 119 120 |
# File 'lib/protoncouch.rb', line 118 def not_found? @hash['error'] == 'not_found' ? true : false end |
#raw ⇒ Object
130 131 132 |
# File 'lib/protoncouch.rb', line 130 def raw @hash end |
#reason ⇒ Object
114 115 116 |
# File 'lib/protoncouch.rb', line 114 def reason @hash['error'] ? @hash['reason'] : 'No reason - everything ok' end |
#unauth? ⇒ Boolean
122 123 124 |
# File 'lib/protoncouch.rb', line 122 def unauth? @hash['error'] == 'unauthorized' ? true : false end |