module MultiTenant::ActsAsTenant::TenantHelpers
Public Instance Methods
with_each_tenant() { || ... }
click to toggle source
Loops through each tenant, sets it as current, and yields to any given block. At the end, current is always set back to what it was originally.
# File lib/multi_tenant/acts_as_tenant.rb, line 127 def with_each_tenant old_tenants = self.current_tenants all.each do |tenant| self.current_tenant = tenant yield if block_given? end ensure self.current_tenants = old_tenants end
with_tenant(record_or_identifier) { || ... }
click to toggle source
Sets the given tenant as the current one and yields to a given block. At the end, current is always set back to what it was originally.
# File lib/multi_tenant/acts_as_tenant.rb, line 141 def with_tenant(record_or_identifier) old_tenants = self.current_tenants self.current_tenant = record_or_identifier yield if block_given? ensure self.current_tenants = old_tenants end
with_tenants(records_or_identifiers) { || ... }
click to toggle source
Sets the given array of tenants as the current one and yields to a given block. At the end, current is always set back to what it was originally.
# File lib/multi_tenant/acts_as_tenant.rb, line 153 def with_tenants(records_or_identifiers) old_tenants = self.current_tenants self.current_tenants = records_or_identifiers yield if block_given? ensure self.current_tenants = old_tenants end
without_tenant() { || ... }
click to toggle source
Sets current to nil and yields to the block. At the end, current is always set back to what it was originally.
# File lib/multi_tenant/acts_as_tenant.rb, line 165 def without_tenant old_tenants = self.current_tenants self.current_tenant = nil yield if block_given? ensure self.current_tenants = old_tenants end
Also aliased as: without_tenants