Class: ES::Connection
- Inherits:
-
Object
- Object
- ES::Connection
- Defined in:
- lib/es/connection.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- OK_HTTP_CODES =
[200, 201]
Instance Method Summary collapse
-
#initialize(host, driver) ⇒ Connection
constructor
A new instance of Connection.
- #request(method, path, data = nil) ⇒ Object
Constructor Details
#initialize(host, driver) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 |
# File 'lib/es/connection.rb', line 5 def initialize(host, driver) @host = host @driver = driver end |
Instance Method Details
#request(method, path, data = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/es/connection.rb', line 10 def request(method, path, data = nil) response = translate_request(method, "#{@host}/#{path}", data) raise Error.new(response) unless OK_HTTP_CODES.include?(response.response_code) response.body_str end |