Class: Sequelizer::ConnectionMaker
- Inherits:
-
Object
- Object
- Sequelizer::ConnectionMaker
- Defined in:
- lib/sequelizer/connection_maker.rb
Overview
ConnectionMaker
Class that handles loading/interpreting the database options and creates the Sequel connection. This class is responsible for:
-
Loading configuration from multiple sources
-
Creating standard Sequel database connections
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#connection ⇒ Sequel::Database
Returns a Sequel connection to the database.
-
#initialize(options = nil) ⇒ ConnectionMaker
constructor
Creates a new ConnectionMaker instance.
Constructor Details
#initialize(options = nil) ⇒ ConnectionMaker
Creates a new ConnectionMaker instance.
If no options are provided, attempts to read options from multiple sources in order of precedence:
-
.env file
-
Environment variables
-
config/database.yml
-
~/.config/sequelizer/database.yml
39 40 41 |
# File 'lib/sequelizer/connection_maker.rb', line 39 def initialize( = nil) = Options.new() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/sequelizer/connection_maker.rb', line 20 def end |
Instance Method Details
#connection ⇒ Sequel::Database
Returns a Sequel connection to the database.
This method creates a standard Sequel database connection using the configured options.
54 55 56 57 58 59 60 61 |
# File 'lib/sequelizer/connection_maker.rb', line 54 def connection opts = .to_hash extensions = .extensions conn = create_sequel_connection(opts) conn.extension(*extensions) conn end |