Class: CouchResource::Connection
- Inherits:
-
Object
- Object
- CouchResource::Connection
- Defined in:
- lib/couch_resource/connection.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#site ⇒ Object
Returns the value of attribute site.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #delete(path, headers = {}) ⇒ Object
- #get(path, headers = {}) ⇒ Object
- #head(path, body = '', headers = {}) ⇒ Object
-
#initialize(site) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, body = '', headers = {}) ⇒ Object
- #put(path, body = '', headers = {}) ⇒ Object
Constructor Details
#initialize(site) ⇒ Connection
Returns a new instance of Connection.
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
#password ⇒ Object
Returns the value of attribute password.
63 64 65 |
# File 'lib/couch_resource/connection.rb', line 63 def password @password end |
#site ⇒ Object
Returns the value of attribute site.
63 64 65 |
# File 'lib/couch_resource/connection.rb', line 63 def site @site end |
#timeout ⇒ Object
Returns the value of attribute timeout.
63 64 65 |
# File 'lib/couch_resource/connection.rb', line 63 def timeout @timeout end |
#user ⇒ Object
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 |