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.
58 59 60 61 62 63 64 |
# File 'lib/thinking_sphinx/connection.rb', line 58 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.
56 57 58 |
# File 'lib/thinking_sphinx/connection.rb', line 56 def client @client end |
Instance Method Details
#close ⇒ Object
66 67 68 |
# File 'lib/thinking_sphinx/connection.rb', line 66 def close client.close end |
#execute(statement) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/thinking_sphinx/connection.rb', line 70 def execute(statement) client.query statement rescue => error wrapper = ThinkingSphinx::QueryExecutionError.new error. wrapper.statement = statement raise wrapper end |
#query(statement) ⇒ Object
78 79 80 |
# File 'lib/thinking_sphinx/connection.rb', line 78 def query(statement) client.query statement end |
#query_all(*statements) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/thinking_sphinx/connection.rb', line 82 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 |