Class: DbQueryHelper::Connection::Connector
- Inherits:
-
Object
- Object
- DbQueryHelper::Connection::Connector
- Defined in:
- lib/classes/connector.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #connect_to(params) ⇒ Object
- #disconnect ⇒ Object
- #execute_query ⇒ Object
-
#initialize(params = {}) ⇒ Connector
constructor
A new instance of Connector.
- #set_new_query(new_query) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Connector
Returns a new instance of Connector.
6 7 8 9 |
# File 'lib/classes/connector.rb', line 6 def initialize(params = {}) @query = nil connect_to(params) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/classes/connector.rb', line 4 def client @client end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
4 5 6 |
# File 'lib/classes/connector.rb', line 4 def query @query end |
Instance Method Details
#connect_to(params) ⇒ Object
15 16 17 18 |
# File 'lib/classes/connector.rb', line 15 def connect_to(params) @client = TinyTds::Client.new(params) raise "Connection::TinyTds::UnableToConnect" unless @client.active? end |
#disconnect ⇒ Object
25 26 27 |
# File 'lib/classes/connector.rb', line 25 def disconnect @client.close end |
#execute_query ⇒ Object
20 21 22 23 |
# File 'lib/classes/connector.rb', line 20 def execute_query raise "Connection::TinyTds::CannotExecuteNilQuery" if @query.nil? @client.execute(query) end |
#set_new_query(new_query) ⇒ Object
11 12 13 |
# File 'lib/classes/connector.rb', line 11 def set_new_query(new_query) @query = new_query end |