Module: Sequelizer

Defined in:
lib/sequelizer.rb,
lib/sequelizer/cli.rb,
lib/sequelizer/options.rb,
lib/sequelizer/version.rb,
lib/sequelizer/env_config.rb,
lib/sequelizer/yaml_config.rb,
lib/sequelizer/options_hash.rb,
lib/sequelizer/connection_maker.rb,
lib/sequelizer/gemfile_modifier.rb

Overview

Include this module in any class where you’d like to quickly establish a Sequel connection to a database.

Defined Under Namespace

Classes: CLI, ConnectionMaker, EnvConfig, GemfileModifier, Options, OptionsHash, YamlConfig

Constant Summary collapse

VERSION =

Version for the gem

"0.0.5"

Instance Method Summary collapse

Instance Method Details

#db(options = nil) ⇒ Object

Instantiates and memoizes a database connection. The db method instantiates the connection on the first call and then memoizes itself so only a single connection is used on repeated calls

options

an optional set of database connection options. If no options are provided, options are read from config/database.yml or from .env or from environment variables.


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

def db(options = nil)
  @_sequelizer_db ||= new_db(options)
end

#new_db(options = nil) ⇒ Object

Instantiates and returns a new database connection on each call.

options

an optional set of database connection options. If no options are provided, options are read from config/database.yml or from .env or from environment variables.


23
24
25
# File 'lib/sequelizer.rb', line 23

def new_db(options = nil)
  ConnectionMaker.new(options).connection
end