Module: Sequelinha

Defined in:
lib/sequelinha.rb,
lib/sequelinha/tasks.rb,
lib/sequelinha/config.rb,
lib/sequelinha/connection_url.rb,
lib/sequelinha/adapters/sqlite.rb,
lib/sequelinha/adapters/postgres.rb,
lib/sequelinha/connection_url_factory.rb

Defined Under Namespace

Modules: Adapters Classes: Config, ConnectionURL, ConnectionURLFactory, Tasks

Class Method Summary collapse

Class Method Details

.configObject



19
20
21
# File 'lib/sequelinha.rb', line 19

def self.config
  @config ||= Config.new
end

.configure {|self.config| ... } ⇒ Object

Yields:



23
24
25
26
27
28
29
30
31
32
# File 'lib/sequelinha.rb', line 23

def self.configure
  yield(self.config) if block_given?

  self.config.database_yml ||= "#{self.config.application_root}/config/database.yml"

  # prepares interestie to run like a boss on heroku
  ENV["DATABASE_URL"] ||= Sequelinha.database_url

  self.config
end

.database_urlObject



34
35
36
37
38
39
# File 'lib/sequelinha.rb', line 34

def self.database_url
  env = ENV["RACK_ENV"] || "development"
  config = self.database_config[env]
  connection_url = ConnectionURLFactory.url_for config
  connection_url
end

.establishObject



41
42
43
44
# File 'lib/sequelinha.rb', line 41

def self.establish
  ENV["DATABASE_URL"] = Sequelinha.database_url
  Sequel.connect(ENV["DATABASE_URL"])
end

.implementationsObject



10
11
12
# File 'lib/sequelinha.rb', line 10

def self.implementations
  @implementations ||= []
end

.register(klass, &block) ⇒ Object



14
15
16
17
# File 'lib/sequelinha.rb', line 14

def self.register(klass, &block)
  self.implementations << klass
  self
end