Class: Apartment::Adapters::Mysql2SchemaAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/apartment/adapters/mysql2_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tenantObject (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_modelsObject

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

#resetObject

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