Class: Goz::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/goz/database.rb,
lib/goz/database/migrations.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Migrations

Constant Summary collapse

DB =

Sequel database instance

ENV['GOZ_DATABASE_URL'] ? Sequel.connect( ENV['GOZ_DATABASE_URL'] ) : Sequel.sqlite

Class Method Summary collapse

Class Method Details

.connect!(url) ⇒ Object



45
46
47
48
49
50
# File 'lib/goz/database.rb', line 45

def self.connect!(url)
  self.send( :remove_const, :'DB' ) if self.const_defined?( :'DB' )
  self.const_set :'DB', Sequel.connect(url)
  Goz::Database::Migrations.migrate!
  self.instance
end

.instance {|DB| ... } ⇒ Object

Get database instance

Yields:



55
56
57
58
# File 'lib/goz/database.rb', line 55

def self.instance
  yield DB if block_given?
  DB
end