Class: UniPump::Connection
- Inherits:
-
Object
- Object
- UniPump::Connection
- Defined in:
- lib/unipump/mssql.rb
Instance Method Summary collapse
- #close ⇒ Object
- #connected? ⇒ Boolean
- #exec(sql) ⇒ Object
-
#initialize(credentials = MsSql::CREDENTIALS) ⇒ Connection
constructor
A new instance of Connection.
- #records(sql) ⇒ Object
- #structs(sql) ⇒ Object
Constructor Details
#initialize(credentials = MsSql::CREDENTIALS) ⇒ Connection
Returns a new instance of Connection.
22 23 24 25 |
# File 'lib/unipump/mssql.rb', line 22 def initialize(credentials = MsSql::CREDENTIALS) @connection = MsSql.connect(credentials) ObjectSpace.define_finalizer(self, self.class.finalize(@connection)) end |
Instance Method Details
#close ⇒ Object
28 |
# File 'lib/unipump/mssql.rb', line 28 def close() MsSql.close(@connection) if connected? end |
#connected? ⇒ Boolean
27 |
# File 'lib/unipump/mssql.rb', line 27 def connected?() return MsSql.active?(@connection) rescue MsSql::Error; false end |
#exec(sql) ⇒ Object
29 |
# File 'lib/unipump/mssql.rb', line 29 def exec(sql) do_exec(sql).each end |
#records(sql) ⇒ Object
31 |
# File 'lib/unipump/mssql.rb', line 31 def records(sql) do_exec(sql).each.map end |
#structs(sql) ⇒ Object
30 |
# File 'lib/unipump/mssql.rb', line 30 def structs(sql) do_exec(sql).each.map { |row| OpenStruct.new(row) } end |