Class: Sequelizer::ConnectionMaker
- Inherits:
-
Object
- Object
- Sequelizer::ConnectionMaker
- Defined in:
- lib/sequelizer/connection_maker.rb
Overview
Class that handles loading/interpretting the database options and creates the Sequel connection
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
The options for Sequel.connect.
Instance Method Summary collapse
-
#connection ⇒ Object
Returns a Sequel connection to the database.
-
#initialize(options = nil) ⇒ ConnectionMaker
constructor
Accepts an optional set of database options.
Constructor Details
permalink #initialize(options = nil) ⇒ ConnectionMaker
Accepts an optional set of database options
If no options are provided, attempts to read options from config/database.yml
If config/database.yml doesn’t exist, Dotenv is used to try to load a .env file, then uses any SEQUELIZER_* environment variables as database options
19 20 21 |
# File 'lib/sequelizer/connection_maker.rb', line 19 def initialize( = nil) @options = Options.new() end |
Instance Attribute Details
permalink #options ⇒ Object (readonly)
The options for Sequel.connect
9 10 11 |
# File 'lib/sequelizer/connection_maker.rb', line 9 def @options end |
Instance Method Details
permalink #connection ⇒ Object
Returns a Sequel connection to the database
24 25 26 |
# File 'lib/sequelizer/connection_maker.rb', line 24 def connection Sequel.connect(.to_hash) end |