Module: Sublet
- Defined in:
- lib/sublet.rb,
lib/sublet/core.rb,
lib/sublet/model.rb,
lib/sublet/current.rb,
lib/sublet/version.rb,
lib/sublet/path_resolver.rb,
lib/sublet/controller_helpers.rb
Defined Under Namespace
Modules: ControllerHelpers, Core, Model, PathResolver Classes: Current
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.current_tenant ⇒ Object
Get the current tenant.
-
.current_tenant=(tenant) ⇒ Object
Set the current tenant.
-
.with_tenant(tenant) ⇒ Object
Execute a block with a specific tenant, restoring the previous tenant afterward.
-
.without_tenant ⇒ Object
Execute a block without any tenant context.
Class Method Details
.current_tenant ⇒ Object
Get the current tenant
25 26 27 |
# File 'lib/sublet.rb', line 25 def current_tenant Current.tenant end |
.current_tenant=(tenant) ⇒ Object
Set the current tenant
30 31 32 |
# File 'lib/sublet.rb', line 30 def current_tenant=(tenant) Current.tenant = tenant end |
.with_tenant(tenant) ⇒ Object
Execute a block with a specific tenant, restoring the previous tenant afterward
35 36 37 38 39 40 41 |
# File 'lib/sublet.rb', line 35 def with_tenant(tenant) prev = current_tenant self.current_tenant = tenant yield ensure self.current_tenant = prev end |
.without_tenant ⇒ Object
Execute a block without any tenant context
44 45 46 |
# File 'lib/sublet.rb', line 44 def without_tenant(&) with_tenant(nil, &) end |