Module: Tenantify::Tenant
- Defined in:
- lib/tenantify/tenant.rb
Overview
Class Method Summary collapse
-
.current ⇒ Symbol
Returns the current tenant.
-
.use!(tenant) ⇒ Symbol
Sets the given tenant from now on.
-
.using(tenant) { ... } ⇒ Object
Runs the given block for a tenant.
Class Method Details
.current ⇒ Symbol
Returns the current tenant.
40 41 42 |
# File 'lib/tenantify/tenant.rb', line 40 def self.current Thread.current.thread_variable_get(:tenant) end |
.use!(tenant) ⇒ Symbol
Sets the given tenant from now on.
33 34 35 |
# File 'lib/tenantify/tenant.rb', line 33 def self.use! tenant Thread.current.thread_variable_set(:tenant, tenant) end |
.using(tenant) { ... } ⇒ Object
Runs the given block for a tenant.
20 21 22 23 24 25 26 27 |
# File 'lib/tenantify/tenant.rb', line 20 def self.using tenant original_tenant = Thread.current.thread_variable_get(:tenant) Thread.current.thread_variable_set(:tenant, tenant) yield ensure Thread.current.thread_variable_set(:tenant, original_tenant) end |