Class: SandthornDriverSequel::SequelDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/sandthorn_driver_sequel/sequel_driver.rb

Instance Method Summary collapse

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

Yields:

  • (@db)


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