Class: ThinkingSphinx::Connection::MRI
- Inherits:
-
Object
- Object
- ThinkingSphinx::Connection::MRI
- Defined in:
- lib/thinking_sphinx/connection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #close ⇒ Object
- #execute(statement) ⇒ Object
-
#initialize(address, port, options) ⇒ MRI
constructor
A new instance of MRI.
- #query(statement) ⇒ Object
- #query_all(*statements) ⇒ Object
Constructor Details
#initialize(address, port, options) ⇒ MRI
Returns a new instance of MRI.
59 60 61 62 63 64 65 |
# File 'lib/thinking_sphinx/connection.rb', line 59 def initialize(address, port, ) @client = Mysql2::Client.new({ :host => address, :port => port, :flags => Mysql2::Client::MULTI_STATEMENTS }.merge()) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
57 58 59 |
# File 'lib/thinking_sphinx/connection.rb', line 57 def client @client end |
Instance Method Details
#close ⇒ Object
67 68 69 |
# File 'lib/thinking_sphinx/connection.rb', line 67 def close client.close end |
#execute(statement) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/thinking_sphinx/connection.rb', line 71 def execute(statement) client.query statement rescue => error wrapper = ThinkingSphinx::QueryExecutionError.new error. wrapper.statement = statement raise wrapper end |
#query(statement) ⇒ Object
79 80 81 |
# File 'lib/thinking_sphinx/connection.rb', line 79 def query(statement) client.query statement end |
#query_all(*statements) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/thinking_sphinx/connection.rb', line 83 def query_all(*statements) results = [client.query(statements.join('; '))] results << client.store_result while client.next_result results rescue => error wrapper = ThinkingSphinx::QueryExecutionError.new error. wrapper.statement = statements.join('; ') raise wrapper end |