Module: Buzzard::DBI
- Defined in:
- lib/buzzard/dbi.rb
Defined Under Namespace
Classes: Wrapper
Instance Method Summary collapse
Instance Method Details
#with_db(&block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/buzzard/dbi.rb', line 5 def with_db(&block) dsn = settings.dbi_dsn username = settings.dbi_username password = settings.dbi_password dbh = ::DBI.connect(dsn, username, password) begin return yield Wrapper.new(self, dbh) ensure dbh.disconnect end end |
#with_sql(sql, *params, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/buzzard/dbi.rb', line 18 def with_sql(sql, *params, &block) with_db do |db| db.all(sql, *params, &block) end end |