Class: CouchResource::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Connection

Returns a new instance of Connection.

Raises:

  • (ArgumentError)


66
67
68
69
70
# File 'lib/couch_resource/connection.rb', line 66

def initialize(site)
  raise ArgumentError, 'Missing site URI' unless site
  @user = @password = nil
  self.site = site
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



63
64
65
# File 'lib/couch_resource/connection.rb', line 63

def password
  @password
end

#siteObject

Returns the value of attribute site.



63
64
65
# File 'lib/couch_resource/connection.rb', line 63

def site
  @site
end

#timeoutObject

Returns the value of attribute timeout.



63
64
65
# File 'lib/couch_resource/connection.rb', line 63

def timeout
  @timeout
end

#userObject

Returns the value of attribute user.



63
64
65
# File 'lib/couch_resource/connection.rb', line 63

def user
  @user
end

Instance Method Details

#delete(path, headers = {}) ⇒ Object



84
85
86
87
88
# File 'lib/couch_resource/connection.rb', line 84

def delete(path, headers = {})
  req = Net::HTTP::Delete.new(path)
  set_request_headers(req, headers)
  request(req)
end

#get(path, headers = {}) ⇒ Object



78
79
80
81
82
# File 'lib/couch_resource/connection.rb', line 78

def get(path, headers = {})
  req = Net::HTTP::Get.new(path)
  set_request_headers(req, headers)
  request(req)
end

#head(path, body = '', headers = {}) ⇒ Object



104
105
106
107
# File 'lib/couch_resource/connection.rb', line 104

def head(path, body='', headers = {})
  req = Net::HTTP::Head.new(path)
  request(req)
end

#post(path, body = '', headers = {}) ⇒ Object



97
98
99
100
101
102
# File 'lib/couch_resource/connection.rb', line 97

def post(path, body='', headers = {})
  req = Net::HTTP::Post.new(path)
  set_request_headers(req, headers)
  req.body = body
  request(req)
end

#put(path, body = '', headers = {}) ⇒ Object



90
91
92
93
94
95
# File 'lib/couch_resource/connection.rb', line 90

def put(path, body='', headers = {})
  req = Net::HTTP::Put.new(path)
  set_request_headers(req, headers)
  req.body = body
  request(req)
end