Skip to content

Commit

Permalink
Document public and private API
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Sep 8, 2014
1 parent 3ab0479 commit ad07187
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/memory_test_fix/schema_file_loader.rb
@@ -1,6 +1,8 @@
module MemoryTestFix
# Load Rails schema file into in-memory database.
# @api private
module SchemaFileLoader
# Load the Rails schema file.
def self.load_schema
# TODO: Use tooling provided by rails once support for Rails 3 is dropped.
load "#{Rails.root}/db/schema.rb"
Expand Down
11 changes: 11 additions & 0 deletions lib/memory_test_fix/schema_loader.rb
Expand Up @@ -4,16 +4,27 @@
module MemoryTestFix
# Set up database schema into in-memory database.
class SchemaLoader
# Initialize the schema for an in-memory database, if it is configured. See
# the README for details on how to configure Rails to use an in-memory
# database.
def self.init_schema
new.init_schema
end

# @param [Hash] options The options to configure this instance of SchemaLoader with.
# @option options [Hash] :configuration The configuration of the database connection
# @option options :migrator The migrator to use if configured to use migrations
# @option options :loader The loader to use if configured to not use migrations
# @api private
def initialize(options = {})
@configuration = options[:configuration] || ActiveRecord::Base.connection_config
@migrator = options[:migrator] || ActiveRecord::Migrator
@loader = options[:loader] || SchemaFileLoader
end

# Initialize the schema for the in-memoray database according to the
# configuration passed to the constructor.
# @api private
def init_schema
return unless in_memory_database?

Expand Down

0 comments on commit ad07187

Please sign in to comment.