Class: Apartment::Adapters::Mysql2SchemaAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- Apartment::Adapters::Mysql2SchemaAdapter
- Defined in:
- lib/apartment/adapters/mysql2_adapter.rb
Instance Attribute Summary collapse
-
#default_tenant ⇒ Object
readonly
Returns the value of attribute default_tenant.
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, #process, #seed_data, #switch
Constructor Details
#initialize(config) ⇒ Mysql2SchemaAdapter
Returns a new instance of Mysql2SchemaAdapter.
35 36 37 38 39 40 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 35 def initialize(config) super @default_tenant = config[:database] reset end |
Instance Attribute Details
#default_tenant ⇒ Object (readonly)
Returns the value of attribute default_tenant.
33 34 35 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 33 def default_tenant @default_tenant end |
Instance Method Details
#process_excluded_models ⇒ Object
Set the table_name to always use the default tenant for excluded models
50 51 52 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 50 def process_excluded_models Apartment.excluded_models.each{ |model| process_excluded_model(model) } end |
#reset ⇒ Object
Reset current_tenant to the default_tenant
44 45 46 |
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 44 def reset Apartment.connection.execute "use #{default_tenant}" end |