module MultiTenant::ActsAsTenant
Contains helpers to turn an ActiveRecord model into the tenant source.
Public Instance Methods
acts_as_tenant(using: :code)
click to toggle source
Use this ActiveRecord model as the tenant source.
@param using [String] (optional) column that contains the unique lookup identifier. Defaults to :code.
# File lib/multi_tenant/acts_as_tenant.rb, line 14 def acts_as_tenant(using: :code) cattr_accessor :tenant_identifier, :tenant_thread_var, :raise_on_tenant_not_found self.tenant_identifier = using self.tenant_thread_var = "current_tenant_#{object_id}".freeze # allows there to be multiple tenant classes self.raise_on_tenant_not_found = true self.extend MultiTenant::ActsAsTenant::TenantGetters self.extend MultiTenant::ActsAsTenant::TenantSetters self.extend MultiTenant::ActsAsTenant::TenantHelpers end
acts_as_tenant?()
click to toggle source
Returns true if this model is being used as a tenant.
@return [Boolean]
# File lib/multi_tenant/acts_as_tenant.rb, line 29 def acts_as_tenant? respond_to? :tenant_identifier end