Class: RSolr::HTTPClient::Base
- Inherits:
-
Object
- Object
- RSolr::HTTPClient::Base
- Defined in:
- lib/rsolr/http_client.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#get(path, params = {}) ⇒ Object
sends a GET reqest to the “path” variable an optional hash of “params” can be used, which is later transformed into a GET query string.
-
#initialize(adapter) ⇒ Base
constructor
requires an instace of RSolr::HTTPClient::*.
-
#post(path, data, params = {}, headers = {}) ⇒ Object
sends a POST request to the “path” variable “data” is required, and must be a string “params” is an optional hash for query string params…
Constructor Details
#initialize(adapter) ⇒ Base
requires an instace of RSolr::HTTPClient::*
40 41 42 |
# File 'lib/rsolr/http_client.rb', line 40 def initialize(adapter) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
37 38 39 |
# File 'lib/rsolr/http_client.rb', line 37 def adapter @adapter end |
Instance Method Details
#get(path, params = {}) ⇒ Object
sends a GET reqest to the “path” variable an optional hash of “params” can be used, which is later transformed into a GET query string
47 48 49 50 51 52 53 54 |
# File 'lib/rsolr/http_client.rb', line 47 def get(path, params={}) begin http_context = @adapter.get(path, params) rescue raise RSolr::RequestError.new($!) end http_context end |
#post(path, data, params = {}, headers = {}) ⇒ Object
sends a POST request to the “path” variable “data” is required, and must be a string “params” is an optional hash for query string params… “headers” is a hash for setting request header values.
60 61 62 63 64 65 66 67 |
# File 'lib/rsolr/http_client.rb', line 60 def post(path, data, params={}, headers={}) begin http_context = @adapter.post(path, data, params, headers) rescue raise RSolr::RequestError.new($!) end http_context end |