Class: MemoryTestFix::SchemaLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/memory_test_fix/schema_loader.rb

Overview

Set up database schema into in-memory database.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SchemaLoader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SchemaLoader.

Parameters:

  • options (Hash) (defaults to: {})

    The options to configure this instance of SchemaLoader with.

Options Hash (options):

  • :configuration (Hash)

    The configuration of the database connection

  • :migrator (Object)

    The migrator to use if configured to use migrations

  • :loader (Object)

    The loader to use if configured to not use migrations



19
20
21
22
23
# File 'lib/memory_test_fix/schema_loader.rb', line 19

def initialize(options = {})
  @configuration = options[:configuration] || ActiveRecord::Base.connection_config
  @migrator = options[:migrator] || ActiveRecord::Migrator
  @loader = options[:loader] || SchemaFileLoader
end

Class Method Details

.init_schemaObject

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.



10
11
12
# File 'lib/memory_test_fix/schema_loader.rb', line 10

def self.init_schema
  new.init_schema
end

Instance Method Details

#init_schemaObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the schema for the in-memoray database according to the configuration passed to the constructor.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/memory_test_fix/schema_loader.rb', line 28

def init_schema
  return unless in_memory_database?

  inform_using_in_memory unless silent?

  if silent? || quiet?
    load_schema_silently
  else
    load_schema
  end
end