module Apartment

def self.const_missing(const_name)

def self.const_missing(const_name)
  super unless const_name == :Database
  warn "`Apartment::Database` has been deprecated. Use `Apartment::Tenant` instead."
  Tenant
end

def configure

configure apartment with available options
def configure
  yield self if block_given?
end

def connection_class

def connection_class
  @connection_class || ActiveRecord::Base
end

def database_names

def database_names
  warn "[Deprecation Warning] `database_names` is now deprecated, please use `tenant_names`"
  tenant_names
end

def database_names=(names)

def database_names=(names)
  warn "[Deprecation Warning] `database_names=` is now deprecated, please use `tenant_names=`"
  self.tenant_names=(names)
end

def database_schema_file

def database_schema_file
  return @database_schema_file if defined?(@database_schema_file)
  @database_schema_file = Rails.root.join('db', 'schema.rb')
end

def db_migrate_tenants

defaults to true
Whether or not db:migrate should also migrate tenants
def db_migrate_tenants
  return @db_migrate_tenants if defined?(@db_migrate_tenants)
  @db_migrate_tenants = true
end

def default_schema

def default_schema
  @default_schema || "public"
end

def excluded_models

Default to empty array
def excluded_models
  @excluded_models || []
end

def persistent_schemas

def persistent_schemas
  @persistent_schemas || []
end

def reset

Reset all the config for Apartment
def reset
  (ACCESSOR_METHODS + WRITER_METHODS).each{|method| remove_instance_variable(:"@#{method}") if instance_variable_defined?(:"@#{method}") }
end

def tenant_names

Be careful not to use `return` here so both Proc and lambda can be used without breaking
def tenant_names
  @tenant_names.respond_to?(:call) ? @tenant_names.call : @tenant_names
end

def tld_length

def tld_length
  @tld_length || 1
end

def use_postgres_schemas

def use_postgres_schemas
  warn "[Deprecation Warning] `use_postgresql_schemas` is now deprecated, please use `use_schemas`"
  use_schemas
end

def use_postgres_schemas=(to_use_or_not_to_use)

def use_postgres_schemas=(to_use_or_not_to_use)
  warn "[Deprecation Warning] `use_postgresql_schemas=` is now deprecated, please use `use_schemas=`"
  self.use_schemas = to_use_or_not_to_use
end