Class: RubyPitaya::DatabaseConnector
- Inherits:
-
Object
- Object
- RubyPitaya::DatabaseConnector
- Defined in:
- lib/rubypitaya/core/database_connector.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #disconnect ⇒ Object
-
#initialize(setup, logger = nil) ⇒ DatabaseConnector
constructor
A new instance of DatabaseConnector.
Constructor Details
#initialize(setup, logger = nil) ⇒ DatabaseConnector
Returns a new instance of DatabaseConnector.
8 9 10 11 12 13 |
# File 'lib/rubypitaya/core/database_connector.rb', line 8 def initialize(setup, logger = nil) @database_config = DatabaseConfig.new(setup) @logger = ActiveSupport::Logger.new(STDOUT) # TODO: Use this # @logger = logger || ActiveSupport::Logger.new(STDOUT) end |
Instance Method Details
#connect ⇒ Object
15 16 17 18 19 |
# File 'lib/rubypitaya/core/database_connector.rb', line 15 def connect ActiveRecord::Base.establish_connection(@database_config.connection_data) ActiveRecord::Base.logger = @logger ActiveSupport::LogSubscriber.colorize_logging = true end |
#disconnect ⇒ Object
21 22 23 |
# File 'lib/rubypitaya/core/database_connector.rb', line 21 def disconnect ActiveRecord::Base.connection.close end |