Module: RSolr::HTTPClient

Defined in:
lib/rsolr/http_client.rb

Defined Under Namespace

Modules: Adapter, Util Classes: Base, UnkownAdapterError

Class Method Summary collapse

Class Method Details

.connect(*args) ⇒ Object

Factory for creating connections. Can specify the connection type by using :net_http or :curb for the first argument. The ending arguments are always used for the connection adapter instance.

Examples: # default net_http connection RSolr::HTTPClient.connect :url=>” # SAME AS RSolr::HTTPClient.connect :net_http, :url=>” # curb connection RSolr.connect :curb, :url=>”



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rsolr/http_client.rb', line 83

def self.connect(*args)
  type = args.first.is_a?(Symbol) ? args.shift : :net_http
  opts = args
  klass = case type
  when :net_http,nil
    'NetHTTP'
  when :curb
    'Curb'
  else
    raise UnkownAdapterError.new("Invalid adapter type: #{type} - use :curb or :net_http or blank for :net_http/default")
  end
  begin
    Base.new Adapter.const_get(klass).new(*args)
  end
end