Module: RSolr

Extended by:
Char
Defined in:
lib/rsolr.rb

Defined Under Namespace

Modules: Char, Connection, Message Classes: Client, RequestError

Constant Summary collapse

VERSION =
'0.9.7.2'

Class Method Summary collapse

Methods included from Char

escape

Class Method Details

.connect(*args) ⇒ Object

Factory for creating connections. 2 modes of argument operations:

1. first argument is solr-adapter type, second arg is options hash for solr-adapter instance.
2. options hash for solr-adapter only (no adapter type as first arg)

Examples: # default http connection RSolr.connect # http connection with custom url RSolr.connect :url=>‘solr.web100.org’ # direct connection RSolr.connect :direct, :home_dir=>‘solr’, :dist_dir=>‘solr-nightly’



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rsolr.rb', line 29

def self.connect(*args)
  type = args.first.is_a?(Symbol) ? args.shift : :http
  opts = args
  type_class = case type
    when :net_http,:http,nil
      'NetHttp'
    when :direct
      'Direct'
    else
      raise "Invalid connection type: #{type} - use :http, :direct or leave nil for :http/default"
    end
  adapter_class = RSolr::Connection.const_get(type_class)
  adapter = adapter_class.new(*opts)
  RSolr::Client.new(adapter)
end