module Innkeeper

Require this file to append Innkeeper rake tasks to ActiveRecord db rake tasks Enabled by default in the initializer

Constants

ACCESSOR_METHODS
AdapterNotFound

Raised when innkeeper cannot find the adapter specified in config/database.yml

InnkeeperError

Exceptions

OTHER_METHODS
TenantExists

The Tenant attempting to be created already exists

TenantNotFound

Tenant specified is unknown

VERSION
WRITER_METHODS

Public Class Methods

configure() { |self| ... } click to toggle source
# File lib/innkeeper.rb, line 28
def configure
  yield self if block_given?
end
connection_class() click to toggle source
# File lib/innkeeper.rb, line 74
def connection_class
  @connection_class || ActiveRecord::Base
end
database_schema_file() click to toggle source
# File lib/innkeeper.rb, line 78
def database_schema_file
  return @database_schema_file if defined?(@database_schema_file)

  @database_schema_file = Rails.root.join('db', 'schema.rb')
end
db_migrate_tenants() click to toggle source

Whether or not db:migrate should also migrate tenants defaults to true

# File lib/innkeeper.rb, line 51
def db_migrate_tenants
  return @db_migrate_tenants if defined?(@db_migrate_tenants)

  @db_migrate_tenants = true
end
default_tenant() click to toggle source
# File lib/innkeeper.rb, line 62
def default_tenant
  @default_tenant || tenant_resolver.init_config
end
excluded_models() click to toggle source

Default to empty array

# File lib/innkeeper.rb, line 58
def excluded_models
  @excluded_models || []
end
parallel_migration_threads() click to toggle source
# File lib/innkeeper.rb, line 66
def parallel_migration_threads
  @parallel_migration_threads || 0
end
persistent_schemas() click to toggle source
# File lib/innkeeper.rb, line 70
def persistent_schemas
  @persistent_schemas || []
end
reset() click to toggle source
# File lib/innkeeper.rb, line 90
def reset
  (ACCESSOR_METHODS + WRITER_METHODS + OTHER_METHODS).each do |method|
    remove_instance_variable(:"@#{method}") if instance_variable_defined?(:"@#{method}")
  end

  Thread.current[:_innkeeper_connection_specification_name] = nil
end
seed_data_file() click to toggle source
# File lib/innkeeper.rb, line 84
def seed_data_file
  return @seed_data_file if defined?(@seed_data_file)

  @seed_data_file = Rails.root.join('db', 'seeds.rb')
end
tenant_names() click to toggle source
# File lib/innkeeper.rb, line 41
def tenant_names
  @tenant_names.respond_to?(:call) ? @tenant_names.call : (@tenant_names || [])
end
tenant_resolver() click to toggle source
# File lib/innkeeper.rb, line 32
def tenant_resolver
  @tenant_resolver ||= @resolver_class.new(connection_config)
end
tenant_resolver=(resolver_class) click to toggle source
# File lib/innkeeper.rb, line 36
def tenant_resolver=(resolver_class)
  remove_instance_variable(:@tenant_resolver) if instance_variable_defined?(:@tenant_resolver)
  @resolver_class = resolver_class
end
tenants_with_config() click to toggle source
# File lib/innkeeper.rb, line 45
def tenants_with_config
  extract_tenant_config
end