Class: RSolr::HTTPClient::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rsolr/http_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#adapterObject (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