lib/apartment/tenant.rb in apartment-0.26.1 vs lib/apartment/tenant.rb in apartment-1.0.0
- old
+ new
@@ -1,16 +1,17 @@
require 'forwardable'
+require 'apartment/deprecation'
module Apartment
# The main entry point to Apartment functions
#
module Tenant
extend self
extend Forwardable
- def_delegators :adapter, :create, :current_tenant, :current, :current_database, :drop, :process, :process_excluded_models, :reset, :seed, :switch
+ def_delegators :adapter, :create, :current_tenant, :current, :current_database, :default_tenant, :drop, :switch, :process_excluded_models, :reset, :seed, :switch!
attr_writer :config
# Initialize Apartment config options such as excluded_models
#
@@ -58,16 +59,18 @@
private
# Fetch the rails database configuration
#
def config
- @config ||= (ActiveRecord::Base.configurations[Rails.env] ||
- Rails.application.config.database_configuration[Rails.env]).symbolize_keys
+ @config ||= Apartment.connection_config
end
end
def self.const_missing(const_name)
- super unless const_name == :Database
- warn "`Apartment::Database` has been deprecated. Use `Apartment::Tenant` instead."
- Tenant
+ if const_name == :Database
+ Apartment::Deprecation.warn "`Apartment::Database` has been deprecated. Use `Apartment::Tenant` instead."
+ Tenant
+ else
+ super
+ end
end
-end
\ No newline at end of file
+end