Class: Apartment::Adapters::Mysql2SchemaAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- Apartment::Adapters::Mysql2SchemaAdapter
- Defined in:
- lib/apartment/adapters/mysql2_adapter.rb
Instance Attribute Summary
Attributes inherited from AbstractAdapter
Instance Method Summary collapse
-
#initialize(config) ⇒ Mysql2SchemaAdapter
constructor
A new instance of Mysql2SchemaAdapter.
-
#process_excluded_models ⇒ Object
Set the table_name to always use the default tenant for excluded models.
-
#reset ⇒ Object
Reset current tenant to the default_tenant.
Methods inherited from AbstractAdapter
#create, #current, #current_database, #current_tenant, #drop, #each, #process, #seed_data, #switch, #switch!
Constructor Details
#initialize(config) ⇒ Mysql2SchemaAdapter
Returns a new instance of Mysql2SchemaAdapter.
39 40 41 42 43 44 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 39 def initialize(config) super @default_tenant = config[:database] reset end |
Instance Method Details
#process_excluded_models ⇒ Object
Set the table_name to always use the default tenant for excluded models
54 55 56 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 54 def process_excluded_models Apartment.excluded_models.each{ |model| process_excluded_model(model) } end |
#reset ⇒ Object
Reset current tenant to the default_tenant
48 49 50 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 48 def reset Apartment.connection.execute "use #{default_tenant}" end |