Class: Protons8::ProtonCouch::CouchResponse::BaseResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/protoncouch.rb

Overview

Add several methods to all type of response

Direct Known Subclasses

Get, PutPostDelete, View

Instance Method Summary collapse

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 attachment(id)
	@hash['_attachments'] ? @hash['_attachments'][id] : nil
end

#attachmentsObject



134
135
136
# File 'lib/protoncouch.rb', line 134

def attachments
	@hash['_attachments'] || nil
end

#conflict?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/protoncouch.rb', line 126

def conflict?
	@hash['error'] == 'conflict' ? true : false
end

#error?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/protoncouch.rb', line 102

def error?
	not @hash['error'].nil?
end

#error_nameObject



110
111
112
# File 'lib/protoncouch.rb', line 110

def error_name
	@hash['error'] || 'No error'
end

#no_error?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/protoncouch.rb', line 106

def no_error?
	@hash['error'].nil?
end

#not_found?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/protoncouch.rb', line 118

def not_found?
	@hash['error'] == 'not_found' ? true : false
end

#rawObject



130
131
132
# File 'lib/protoncouch.rb', line 130

def raw
	@hash
end

#reasonObject



114
115
116
# File 'lib/protoncouch.rb', line 114

def reason
	@hash['error'] ? @hash['reason'] : 'No reason - everything ok'
end

#unauth?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/protoncouch.rb', line 122

def unauth?
	@hash['error'] == 'unauthorized' ? true : false
end