Module: RSolr
- Extended by:
- Char
- Defined in:
- lib/rsolr.rb
Defined Under Namespace
Modules: Char, Connection, HTTPClient, Message Classes: RequestError
Constant Summary collapse
- VERSION =
'0.9.5'
Class Method Summary collapse
-
.connect(*args) ⇒ Object
Factory for creating connections.
Methods included from Char
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’
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rsolr.rb', line 27 def self.connect(*args) type = args.first.is_a?(Symbol) ? args.shift : :http opts = args type_class = case type when :http,nil 'HTTP' when :direct 'Direct' else raise "Invalid connection type: #{type} - use :http, :direct or leave nil for :http/default" end adapter_class = RSolr::Connection::Adapter.const_get(type_class) adapter = adapter_class.new(*opts) RSolr::Connection::Base.new(adapter) end |