Class: Squixtures::SQLite3Helper
- Inherits:
-
Object
- Object
- Squixtures::SQLite3Helper
- Defined in:
- lib/squixtures/sqlite3_helper.rb
Overview
A class to contain elements specific to the SQLite3 system.
Class Method Summary collapse
-
.get_connection_url(settings) ⇒ Object
This method converts a typical set of database connection settings, such as those in a Rails database.yml file, into the URL to be used to connect to a Postgres database using the Sequel library.
Instance Method Summary collapse
-
#after_load(fixtures, connection) ⇒ Object
This method is invoked immediately after a fixture load completes and performs all clean up necessary.
-
#before_load(fixtures, connection) ⇒ Object
This method is invoked immediately before a fixture load starts and performs all work necessary to facilitate the load.
-
#get_connection_url(settings) ⇒ Object
This method is an instance level version of the get_connection_url method declared at the class level.
Class Method Details
.get_connection_url(settings) ⇒ Object
This method converts a typical set of database connection settings, such as those in a Rails database.yml file, into the URL to be used to connect to a Postgres database using the Sequel library.
Parameters
- settings
-
A Hash of the settings that will be used to generate the connection URL.
47 48 49 |
# File 'lib/squixtures/sqlite3_helper.rb', line 47 def self.get_connection_url(settings) "sqlite://#{settings['database']}" end |
Instance Method Details
#after_load(fixtures, connection) ⇒ Object
This method is invoked immediately after a fixture load completes and performs all clean up necessary.
Parameters
- fixtures
-
A collection of the fixture objects to be loaded.
- connection
-
The database connection that the load will be performed through.
29 30 31 32 |
# File 'lib/squixtures/sqlite3_helper.rb', line 29 def after_load(fixtures, connection) SQLite3Helper.log.debug "SQLite3Helper.after_load called." connection.run("PRAGMA foreign_keys = ON") end |
#before_load(fixtures, connection) ⇒ Object
This method is invoked immediately before a fixture load starts and performs all work necessary to facilitate the load.
Parameters
- fixtures
-
A collection of the fixture objects to be loaded.
- connection
-
The database connection that the load will be performed through.
17 18 19 20 |
# File 'lib/squixtures/sqlite3_helper.rb', line 17 def before_load(fixtures, connection) SQLite3Helper.log.debug "SQLite3Helper.before_load called." connection.run("PRAGMA foreign_keys = OFF") end |
#get_connection_url(settings) ⇒ Object
This method is an instance level version of the get_connection_url method declared at the class level.
36 37 38 |
# File 'lib/squixtures/sqlite3_helper.rb', line 36 def get_connection_url(settings) SQLite3Helper.get_connection_url(settings) end |