@@ -21,10 +21,6 @@ def tenanted?
2121 true
2222 end
2323
24- def tenanted_config_name
25- @tenanted_config_name ||= ( superclass . respond_to? ( :tenanted_config_name ) ? superclass . tenanted_config_name : nil )
26- end
27-
2824 def current_tenant
2925 shard = current_shard
3026 shard != UNTENANTED_SENTINEL ? shard . to_s : nil
@@ -45,11 +41,6 @@ def while_tenanted(tenant_name, prohibit_shard_swapping: true, &block)
4541 end
4642 end
4743
48- # This method is really only intended to be used for testing.
49- def while_untenanted ( &block ) # :nodoc:
50- while_tenanted ( ActiveRecord ::Tenanted ::Tenant ::UNTENANTED_SENTINEL , prohibit_shard_swapping : false , &block )
51- end
52-
5344 def create_tenant ( tenant_name , &block )
5445 raise TenantExistsError if tenant_exist? ( tenant_name )
5546
@@ -71,6 +62,11 @@ def destroy_tenant(tenant_name)
7162 FileUtils . rm ( tenanted_root_config . database_path_for ( tenant_name ) )
7263 end
7364
65+ # This method is really only intended to be used for testing.
66+ def while_untenanted ( &block ) # :nodoc:
67+ while_tenanted ( ActiveRecord ::Tenanted ::Tenant ::UNTENANTED_SENTINEL , prohibit_shard_swapping : false , &block )
68+ end
69+
7470 def connection_pool # :nodoc:
7571 raise NoTenantError unless current_tenant
7672
@@ -127,6 +123,10 @@ def ensure_schema_migrations(config) # :nodoc:
127123 def tenanted_root_config # :nodoc:
128124 ActiveRecord ::Base . configurations . resolve ( tenanted_config_name . to_sym )
129125 end
126+
127+ def tenanted_config_name # :nodoc:
128+ @tenanted_config_name ||= ( superclass . respond_to? ( :tenanted_config_name ) ? superclass . tenanted_config_name : nil )
129+ end
130130 end
131131 end
132132 end
0 commit comments