Class: CouchModel::Server
- Inherits:
-
Object
- Object
- CouchModel::Server
- Defined in:
- lib/couch_model/server.rb
Overview
The Server class provides methods to retrieve informations and statistics of a CouchDB server.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #database_names ⇒ Object
- #informations ⇒ Object
-
#initialize(options = { }) ⇒ Server
constructor
A new instance of Server.
- #statistics ⇒ Object
- #url ⇒ Object
- #uuids(count = 1) ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ Server
Returns a new instance of Server.
12 13 14 15 |
# File 'lib/couch_model/server.rb', line 12 def initialize( = { }) @host = [:host] || "localhost" @port = [:port] || "5984" end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/couch_model/server.rb', line 9 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/couch_model/server.rb', line 10 def port @port end |
Instance Method Details
#==(other) ⇒ Object
17 18 19 |
# File 'lib/couch_model/server.rb', line 17 def ==(other) other.is_a?(self.class) && @host == other.host && @port == other.port end |
#database_names ⇒ Object
29 30 31 |
# File 'lib/couch_model/server.rb', line 29 def database_names Transport::JSON.request :get, url + "/_all_dbs", :expected_status_code => 200 end |
#informations ⇒ Object
21 22 23 |
# File 'lib/couch_model/server.rb', line 21 def informations Transport::JSON.request :get, url + "/", :expected_status_code => 200 end |
#statistics ⇒ Object
25 26 27 |
# File 'lib/couch_model/server.rb', line 25 def statistics Transport::JSON.request :get, url + "/_stats", :expected_status_code => 200 end |
#url ⇒ Object
38 39 40 |
# File 'lib/couch_model/server.rb', line 38 def url "http://#{@host}:#{@port}" end |