module Apartment::Database
def self.mysql_adapter(config)
def self.mysql_adapter(config) Adapters::MysqlAdapter.new config end
def self.postgresql_adapter(config)
def self.postgresql_adapter(config) Apartment.use_postgres_schemas ? Adapters::PostgresqlSchemaAdapter.new(config, :schema_search_path => ActiveRecord::Base.connection.schema_search_path) : Adapters::PostgresqlAdapter.new(config) end
def adapter
-
(subclass of Apartment::AbstractAdapter)
-
def adapter @adapter ||= begin adapter_method = "#{config[:adapter]}_adapter" begin require "apartment/adapters/#{adapter_method}" rescue LoadError => e raise "The adapter `#{config[:adapter]}` is not yet supported" end unless respond_to?(adapter_method) raise AdapterNotFound, "database configuration specifies nonexistent #{config[:adapter]} adapter" end send(adapter_method, config) end end
def config
Fetch the rails database configuration
def config @config ||= Rails.configuration.database_configuration[Rails.env].symbolize_keys end
def init
Initialize Apartment config options such as excluded_models
def init process_excluded_models end
def reload!
Reset config and adapter so they are regenerated
def reload! @adapter = nil @config = nil end