Module: Multitenant
- Defined in:
- lib/multitenant.rb,
lib/multitenant/version.rb
Overview
Multitenant: making cross tenant data leaks a thing of the past…since 2011
Defined Under Namespace
Modules: ActiveRecordExtensions
Constant Summary collapse
- VERSION =
'1.0.0'
Class Method Summary collapse
- .current_tenant ⇒ Object
- .current_tenant=(value) ⇒ Object
-
.with_tenant(tenant, &block) ⇒ Object
execute a block scoped to the current tenant unsets the current tenant after execution.
Class Method Details
.current_tenant ⇒ Object
10 11 12 |
# File 'lib/multitenant.rb', line 10 def current_tenant Thread.current[:current_tenant] end |
.current_tenant=(value) ⇒ Object
6 7 8 |
# File 'lib/multitenant.rb', line 6 def current_tenant=(value) Thread.current[:current_tenant] = value end |
.with_tenant(tenant, &block) ⇒ Object
execute a block scoped to the current tenant unsets the current tenant after execution
16 17 18 19 20 21 |
# File 'lib/multitenant.rb', line 16 def with_tenant(tenant, &block) Multitenant.current_tenant = tenant yield ensure Multitenant.current_tenant = nil end |