Class: Protons8::Couch::CouchResponse::BaseResponse
- Inherits:
-
Object
- Object
- Protons8::Couch::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.
97 98 99 |
# File 'lib/protoncouch.rb', line 97 def initialize(hash) @hash = hash end |
Instance Method Details
#attachment(id) ⇒ Object
137 138 139 |
# File 'lib/protoncouch.rb', line 137 def (id) @hash['_attachments'] ? @hash['_attachments'][id] : nil end |
#attachments ⇒ Object
133 134 135 |
# File 'lib/protoncouch.rb', line 133 def @hash['_attachments'] || nil end |
#conflict? ⇒ Boolean
125 126 127 |
# File 'lib/protoncouch.rb', line 125 def conflict? @hash['error'] == 'conflict' ? true : false end |
#error? ⇒ Boolean
101 102 103 |
# File 'lib/protoncouch.rb', line 101 def error? not @hash['error'].nil? end |
#error_name ⇒ Object
109 110 111 |
# File 'lib/protoncouch.rb', line 109 def error_name @hash['error'] || 'No error' end |
#no_error? ⇒ Boolean
105 106 107 |
# File 'lib/protoncouch.rb', line 105 def no_error? @hash['error'].nil? end |
#not_found? ⇒ Boolean
117 118 119 |
# File 'lib/protoncouch.rb', line 117 def not_found? @hash['error'] == 'not_found' ? true : false end |
#raw ⇒ Object
129 130 131 |
# File 'lib/protoncouch.rb', line 129 def raw @hash end |
#reason ⇒ Object
113 114 115 |
# File 'lib/protoncouch.rb', line 113 def reason @hash['error'] ? @hash['reason'] : 'No reason - everything ok' end |
#unauth? ⇒ Boolean
121 122 123 |
# File 'lib/protoncouch.rb', line 121 def unauth? @hash['error'] == 'unauthorized' ? true : false end |