Class: Hippo::Tenant

Inherits:
Model
  • Object
show all
Defined in:
lib/hippo/tenant.rb

Overview

Tenant

Constant Summary

Constants included from Concerns::ApiAttributeAccess

Concerns::ApiAttributeAccess::DEFAULT_BLACKLISTED

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

belongs_to_tenant, scoped_by_tenant?

Methods included from Concerns::ApiAttributeAccess

#_set_attribute_data_from_collection, #set_attribute_data, #setting_attribute_is_allowed?

Class Method Details

.currentObject



25
26
27
# File 'lib/hippo/tenant.rb', line 25

def self.current
    MultiTenant.current_tenant
end

.switch(condition) ⇒ Object



36
37
38
# File 'lib/hippo/tenant.rb', line 36

def self.switch(condition)
    MultiTenant.current_tenant = self.find_by(condition)
end

.systemObject



29
30
31
32
33
34
# File 'lib/hippo/tenant.rb', line 29

def self.system
    find_by(slug: 'system') || create!(
        slug: 'system', name: 'system',
        email: '[email protected]', subscription: :admin
    )
end

Instance Method Details

#domainObject



15
16
17
# File 'lib/hippo/tenant.rb', line 15

def domain
    self.slug + '.' + Hippo.config.website_domain
end

#performObject



19
20
21
22
23
# File 'lib/hippo/tenant.rb', line 19

def perform
    MultiTenant.with(self) do
        yield
    end
end