Module: Multitenant::IsMultitenant::SingletonMethods

Defined in:
lib/is_multitenant.rb

Overview

These methods are available as class level methods to the models that invoke is_multitenant, and only to those models.

Instance Method Summary collapse

Instance Method Details

#current_tenant_idObject



120
121
122
# File 'lib/is_multitenant.rb', line 120

def current_tenant_id
  Multitenant.current_tenant_id
end

#is_multitenant?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/is_multitenant.rb', line 111

def is_multitenant?
  true
end

#tenant_condition(tenant_id = nil) ⇒ Object



115
116
117
118
# File 'lib/is_multitenant.rb', line 115

def tenant_condition(tenant_id = nil)
  raise 'ERROR: the current tenant id has not been set' unless tenant_id || current_tenant_id
  {self.tenant_attribute => tenant_id || current_tenant_id}
end