Class: SandthornDriverSequel::SequelDriver
- Inherits:
-
Object
- Object
- SandthornDriverSequel::SequelDriver
- Defined in:
- lib/sandthorn_driver_sequel/sequel_driver.rb
Instance Method Summary collapse
- #execute {|@db| ... } ⇒ Object
- #execute_in_transaction(&block) ⇒ Object
-
#initialize(args = {}) ⇒ SequelDriver
constructor
A new instance of SequelDriver.
Constructor Details
#initialize(args = {}) ⇒ SequelDriver
Returns a new instance of SequelDriver.
6 7 8 9 10 11 |
# File 'lib/sandthorn_driver_sequel/sequel_driver.rb', line 6 def initialize(args = {}) Sequel.default_timezone = :utc @db = args.fetch(:connection) { Sequel.connect(args.fetch(:url)) } end |
Instance Method Details
#execute {|@db| ... } ⇒ Object
13 14 15 |
# File 'lib/sandthorn_driver_sequel/sequel_driver.rb', line 13 def execute yield @db end |
#execute_in_transaction(&block) ⇒ Object
17 18 19 20 21 |
# File 'lib/sandthorn_driver_sequel/sequel_driver.rb', line 17 def execute_in_transaction &block @db.transaction do block.call(@db) end end |