Class: ThinkingSphinx::Connection::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/connection/client.rb

Direct Known Subclasses

JRuby, MRI

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/thinking_sphinx/connection/client.rb', line 4

def initialize(options)
  if options[:socket].present?
    options[:socket] = options[:socket].remove /:mysql41$/

    options.delete :host
    options.delete :port
  else
    options.delete :socket

    # If you use localhost, MySQL insists on a socket connection, but in this
    # situation we want a TCP connection. Using 127.0.0.1 fixes that.
    if options[:host].nil? || options[:host] == "localhost"
      options[:host] = "127.0.0.1"
    end
  end

  @options = options
end

Instance Method Details

#closeObject



23
24
25
# File 'lib/thinking_sphinx/connection/client.rb', line 23

def close
  close! unless ThinkingSphinx::Connection.persistent?
end

#close!Object



27
28
29
# File 'lib/thinking_sphinx/connection/client.rb', line 27

def close!
  client.close
end

#execute(statement) ⇒ Object



31
32
33
# File 'lib/thinking_sphinx/connection/client.rb', line 31

def execute(statement)
  check_and_perform(statement).first
end

#query_all(*statements) ⇒ Object



35
36
37
# File 'lib/thinking_sphinx/connection/client.rb', line 35

def query_all(*statements)
  check_and_perform statements.join('; ')
end