Module: Apartment::Database
- Defined in:
- lib/apartment/database.rb,
lib/apartment/adapters/postgresql_adapter.rb
Constant Summary collapse
- MULTI_TENANT_METHODS =
[:create, :switch, :reset, :connect_and_reset, :process]
Class Method Summary collapse
- .adapter ⇒ Object
-
.init ⇒ Object
Call init to establish a connection to the public schema on all excluded models This must be done before creating any new schemas or switching.
- .postgresql_adapter(config) ⇒ Object
- .reload! ⇒ Object
Class Method Details
.adapter ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/apartment/database.rb', line 24 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 |
.init ⇒ Object
Call init to establish a connection to the public schema on all excluded models This must be done before creating any new schemas or switching
12 13 14 |
# File 'lib/apartment/database.rb', line 12 def init connect_exclusions end |
.postgresql_adapter(config) ⇒ Object
5 6 7 |
# File 'lib/apartment/adapters/postgresql_adapter.rb', line 5 def self.postgresql_adapter(config) Adapters::PostgresqlAdapter.new config, :schema_search_path => ActiveRecord::Base.connection.schema_search_path end |
.reload! ⇒ Object
42 43 44 45 |
# File 'lib/apartment/database.rb', line 42 def reload! @adapter = nil @config = nil end |