Class: DbAgile::Core::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/dbagile/core/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chain) ⇒ Connection

Creates a database instance with an underlying adapter



10
11
12
# File 'lib/dbagile/core/connection.rb', line 10

def initialize(chain)
  @chain = chain
end

Instance Attribute Details

#chainObject (readonly)

Returns the value of attribute chain.



5
6
7
# File 'lib/dbagile/core/connection.rb', line 5

def chain
  @chain
end

Instance Method Details

#inspectObject

Delegated to the chain



22
23
24
# File 'lib/dbagile/core/connection.rb', line 22

def inspect
  @chain.inspect
end

#plug(*args) ⇒ Object

Hot plug



17
18
19
# File 'lib/dbagile/core/connection.rb', line 17

def plug(*args)
  @chain.plug(*args)
end

#transaction(&block) ⇒ Object

Executes the block inside a transaction.

Raises:

  • (ArgumentError)


44
45
46
47
# File 'lib/dbagile/core/connection.rb', line 44

def transaction(&block)
  raise ArgumentError, "Missing transaction block" unless block
  Transaction.new(self).execute(&block)
end