Class: Hippo::Tenant
- Inherits:
-
Model
- Object
- ActiveRecord::Base
- Model
- Hippo::Tenant
show all
- Defined in:
- lib/hippo/tenant.rb
Overview
Constant Summary
collapse
- PUBLIC_ATTRS =
%w{slug name identifier subscription_id}
Concerns::ApiAttributeAccess::DEFAULT_BLACKLISTED
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
belongs_to_tenant, scoped_by_tenant?
#_set_attribute_data_from_collection, #set_attribute_data, #setting_attribute_is_allowed?
Class Method Details
.current ⇒ Object
43
44
45
|
# File 'lib/hippo/tenant.rb', line 43
def self.current
MultiTenant.current_tenant || system
end
|
.switch(condition) ⇒ Object
53
54
55
|
# File 'lib/hippo/tenant.rb', line 53
def self.switch(condition)
MultiTenant.current_tenant = self.find_by(condition)
end
|
.system ⇒ Object
47
48
49
50
51
|
# File 'lib/hippo/tenant.rb', line 47
def self.system
find_by(slug: 'system') || create!(
slug: 'system', name: 'system', email: '[email protected]'
)
end
|
Instance Method Details
#domain ⇒ Object
23
24
25
|
# File 'lib/hippo/tenant.rb', line 23
def domain
self.slug + '.' + Hippo.config.website_domain
end
|
27
28
29
30
31
|
# File 'lib/hippo/tenant.rb', line 27
def perform
MultiTenant.with(self) do
yield
end
end
|