Module: Sublease
- Defined in:
- lib/sublease.rb,
lib/sublease/engine.rb,
lib/sublease/errors.rb,
lib/sublease/version.rb,
app/models/sublease/lodger.rb,
app/models/sublease/tenant.rb,
lib/sublease/tenant_switcher.rb,
lib/generators/sublease/install/install_generator.rb
Defined Under Namespace
Modules: TenantSwitcher
Classes: ConfigError, Engine, InstallGenerator, Lodger, Tenant, TenantModelNotSet, TenantNotFound
Constant Summary
collapse
- VERSION =
'0.2.3'
- @@current_tenant =
Current tenant information
nil
- @@current_tenant_domain =
nil
- @@current_tenant_subdomain =
nil
- @@default_tenant =
Default tenant information
nil
- @@default_tenant_domain =
nil
- @@default_tenant_subdomain =
nil
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.switch_on_domain ⇒ Object
Returns the value of attribute switch_on_domain.
10
11
12
|
# File 'lib/sublease.rb', line 10
def switch_on_domain
@switch_on_domain
end
|
.switch_on_subdomain ⇒ Object
Returns the value of attribute switch_on_subdomain.
10
11
12
|
# File 'lib/sublease.rb', line 10
def switch_on_subdomain
@switch_on_subdomain
end
|
.switch_on_subdomain_and_domain ⇒ Object
Returns the value of attribute switch_on_subdomain_and_domain.
10
11
12
|
# File 'lib/sublease.rb', line 10
def switch_on_subdomain_and_domain
@switch_on_subdomain_and_domain
end
|
.tenant_model ⇒ Object
Returns the value of attribute tenant_model.
10
11
12
|
# File 'lib/sublease.rb', line 10
def tenant_model
@tenant_model
end
|
Class Method Details
configure sublease with available options
23
24
25
|
# File 'lib/sublease.rb', line 23
def configure
yield self if block_given?
end
|
.current_tenant ⇒ Object
31
32
33
|
# File 'lib/sublease.rb', line 31
def current_tenant
@@current_tenant || default_tenant
end
|
.current_tenant=(tenant) ⇒ Object
27
28
29
|
# File 'lib/sublease.rb', line 27
def current_tenant=(tenant)
@@current_tenant = tenant
end
|
.current_tenant_domain ⇒ Object
39
40
41
|
# File 'lib/sublease.rb', line 39
def current_tenant_domain
@@current_tenant_domain || default_tenant_domain
end
|
.current_tenant_domain=(domain) ⇒ Object
35
36
37
|
# File 'lib/sublease.rb', line 35
def current_tenant_domain=(domain)
@@current_tenant_domain = domain
end
|
.current_tenant_subdomain ⇒ Object
47
48
49
|
# File 'lib/sublease.rb', line 47
def current_tenant_subdomain
@@current_tenant_subdomain || default_tenant_subdomain
end
|
.current_tenant_subdomain=(subdomain) ⇒ Object
43
44
45
|
# File 'lib/sublease.rb', line 43
def current_tenant_subdomain=(subdomain)
@@current_tenant_subdomain = subdomain
end
|
.default_tenant ⇒ Object
56
57
58
|
# File 'lib/sublease.rb', line 56
def default_tenant
@@default_tenant
end
|
.default_tenant=(tenant) ⇒ Object
51
52
53
54
|
# File 'lib/sublease.rb', line 51
def default_tenant=(tenant)
raise Sublease::TenantNotFound if tenant.nil?
@@default_tenant = tenant
end
|
.default_tenant_domain ⇒ Object
72
73
74
|
# File 'lib/sublease.rb', line 72
def default_tenant_domain
@@default_tenant_domain
end
|
.default_tenant_domain=(domain) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/sublease.rb', line 60
def default_tenant_domain=(domain)
tenant_model?
@@default_tenant_domain = domain
unless domain.nil?
if default_tenant_subdomain.nil?
self.default_tenant = tenant_model.where(domain: domain).first
else
self.default_tenant = tenant_model.where(domain: domain, subdomain: default_tenant_subdomain).first
end
end
end
|
.default_tenant_subdomain ⇒ Object
88
89
90
|
# File 'lib/sublease.rb', line 88
def default_tenant_subdomain
@@default_tenant_subdomain
end
|
.default_tenant_subdomain=(subdomain) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/sublease.rb', line 76
def default_tenant_subdomain=(subdomain)
tenant_model?
@@default_tenant_subdomain = subdomain
unless subdomain.nil?
if default_tenant_domain.nil?
self.default_tenant = tenant_model.where(subdomain: subdomain).first
else
self.default_tenant = tenant_model.where(domain: default_tenant_domain, subdomain: subdomain).first
end
end
end
|