class ThinkingSphinx::Connection::Client

Public Instance Methods

close() click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 2
def close
  close! unless ThinkingSphinx::Connection.persistent?
end
close!() click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 6
def close!
  client.close
end
execute(statement) click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 10
def execute(statement)
  check_and_perform(statement).first
end
query_all(*statements) click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 14
def query_all(*statements)
  check_and_perform statements.join('; ')
end

Private Instance Methods

check(statements) click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 20
def check(statements)
  if statements.length > ThinkingSphinx::MAXIMUM_STATEMENT_LENGTH
    exception           = ThinkingSphinx::QueryLengthError.new
    exception.statement = statements
    raise exception
  end
end
check_and_perform(statements) click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 28
def check_and_perform(statements)
  check statements
  perform statements
end
close_and_clear() click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 33
def close_and_clear
  client.close
  @client = nil
end
perform(statements) click to toggle source
# File lib/thinking_sphinx/connection/client.rb, line 38
def perform(statements)
  results_for statements
rescue => error
  message           = "#{error.message} - #{statements}"
  wrapper           = ThinkingSphinx::QueryExecutionError.new message
  wrapper.statement = statements
  raise wrapper
ensure
  close_and_clear unless ThinkingSphinx::Connection.persistent?
end