module MultiTenant::ActsAsTenant::TenantGetters
Public Instance Methods
current_tenant()
click to toggle source
Return the current tenant record, if any. Thread-safe. If there are MULTIPLE current tenants set this will raise a RuntimeError.
@return the current tenant record
# File lib/multi_tenant/acts_as_tenant.rb, line 60 def current_tenant tenants = current_tenants if tenants.size > 1 raise "#{self.name}.current/current_tenant was called when multiple current tenants were present?. Did you mean to call #{self.name}.current_tenants?" else tenants[0] end end
Also aliased as: current
current_tenants()
click to toggle source
Returns the array of current tenants. Thread-safe.
@return the array of tenant records
# File lib/multi_tenant/acts_as_tenant.rb, line 50 def current_tenants Thread.current.thread_variable_get(tenant_thread_var) || [] end
current_tenants?()
click to toggle source
Returns true if there are any current tenants set, false if not.
@return [Boolean]
# File lib/multi_tenant/acts_as_tenant.rb, line 39 def current_tenants? current_tenants.any? end
Also aliased as: current?, current_tenant?