Class: Apartment::Adapters::PostgresqlSchemaAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- Apartment::Adapters::PostgresqlSchemaAdapter
- Defined in:
- lib/apartment/adapters/postgresql_adapter.rb
Overview
Separate Adapter for Postgresql when using schemas
Direct Known Subclasses
Instance Method Summary collapse
- #current ⇒ Object
- #default_tenant ⇒ Object
- #init ⇒ Object
-
#initialize(config) ⇒ PostgresqlSchemaAdapter
constructor
A new instance of PostgresqlSchemaAdapter.
-
#reset ⇒ Object
Reset schema search path to the default schema_search_path.
Methods inherited from AbstractAdapter
#create, #drop, #each, #environmentify, #process_excluded_models, #seed_data, #switch, #switch!
Constructor Details
#initialize(config) ⇒ PostgresqlSchemaAdapter
Returns a new instance of PostgresqlSchemaAdapter.
28 29 30 31 32 |
# File 'lib/apartment/adapters/postgresql_adapter.rb', line 28 def initialize(config) super reset end |
Instance Method Details
#current ⇒ Object
52 53 54 |
# File 'lib/apartment/adapters/postgresql_adapter.rb', line 52 def current @current || default_tenant end |
#default_tenant ⇒ Object
34 35 36 |
# File 'lib/apartment/adapters/postgresql_adapter.rb', line 34 def default_tenant @default_tenant = Apartment.default_tenant || 'public' end |
#init ⇒ Object
47 48 49 50 |
# File 'lib/apartment/adapters/postgresql_adapter.rb', line 47 def init super Apartment.connection.schema_search_path = full_search_path end |
#reset ⇒ Object
Reset schema search path to the default schema_search_path
@return {String} default schema search path
42 43 44 45 |
# File 'lib/apartment/adapters/postgresql_adapter.rb', line 42 def reset @current = default_tenant Apartment.connection.schema_search_path = full_search_path end |