Class: SunspotConnector::Connection
- Inherits:
-
Object
- Object
- SunspotConnector::Connection
- Defined in:
- lib/sunspot_connector/connection.rb
Instance Method Summary collapse
- #build_connection ⇒ Object
- #connect(opts = {}) ⇒ Object
-
#initialize(config = Config.new) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(config = Config.new) ⇒ Connection
Returns a new instance of Connection.
6 7 8 9 |
# File 'lib/sunspot_connector/connection.rb', line 6 def initialize(config = Config.new) raise ArgumentError, 'expected SunspotConnector::Config' unless config.is_a?(Config) @config = config end |
Instance Method Details
#build_connection ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/sunspot_connector/connection.rb', line 15 def build_connection Faraday.new do |conn| conn.headers = { 'Keep-Alive' => 'timeout=10' }.merge(@config.headers) conn.adapter @config.adapter if @config.adapter end end |
#connect(opts = {}) ⇒ Object
11 12 13 |
# File 'lib/sunspot_connector/connection.rb', line 11 def connect(opts = {}) RSolr::Client.new(build_connection, opts) end |