Class: Multitenant::Mysql::Tenant

Inherits:
Object
  • Object
show all
Defined in:
lib/multitenant-mysql/connection_switcher.rb

Class Method Summary collapse

Class Method Details

.exists?(tenant_name) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
# File 'lib/multitenant-mysql/connection_switcher.rb', line 6

def self.exists? tenant_name
  return true if tenant_name.blank?
  tenant = Multitenant::Mysql.configs.tenant
  field = Multitenant::Mysql.configs.bucket.field
  if tenant.where(field => tenant_name).blank?
    raise NoTenantRegistratedError.new("No tenant registered: #{tenant_name}")
  end
  true
end