module Sublease
Constants
- VERSION
Attributes
switch_on_domain[R]
switch_on_subdomain[R]
switch_on_subdomain_and_domain[R]
tenant_model[R]
Public Class Methods
configure() { |self| ... }
click to toggle source
configure sublease with available options
# File lib/sublease.rb, line 23 def configure yield self if block_given? end
current_tenant()
click to toggle source
# File lib/sublease.rb, line 31 def current_tenant @@current_tenant || default_tenant end
current_tenant=(tenant)
click to toggle source
# File lib/sublease.rb, line 27 def current_tenant=(tenant) @@current_tenant = tenant end
current_tenant_domain()
click to toggle source
# File lib/sublease.rb, line 39 def current_tenant_domain @@current_tenant_domain || default_tenant_domain end
current_tenant_domain=(domain)
click to toggle source
# File lib/sublease.rb, line 35 def current_tenant_domain=(domain) @@current_tenant_domain = domain end
current_tenant_subdomain()
click to toggle source
# File lib/sublease.rb, line 47 def current_tenant_subdomain @@current_tenant_subdomain || default_tenant_subdomain end
current_tenant_subdomain=(subdomain)
click to toggle source
# File lib/sublease.rb, line 43 def current_tenant_subdomain=(subdomain) @@current_tenant_subdomain = subdomain end
default_tenant()
click to toggle source
# File lib/sublease.rb, line 56 def default_tenant @@default_tenant end
default_tenant=(tenant)
click to toggle source
# File lib/sublease.rb, line 51 def default_tenant=(tenant) raise Sublease::TenantNotFound if tenant.nil? @@default_tenant = tenant end
default_tenant_domain()
click to toggle source
# File lib/sublease.rb, line 72 def default_tenant_domain @@default_tenant_domain end
default_tenant_domain=(domain)
click to toggle source
# 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()
click to toggle source
# File lib/sublease.rb, line 88 def default_tenant_subdomain @@default_tenant_subdomain end
default_tenant_subdomain=(subdomain)
click to toggle source
# 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
switch_on_domain=(tf)
click to toggle source
# File lib/sublease.rb, line 100 def switch_on_domain=(tf) tenant_model? switch_on_configuration_valid?('domain', tf) @switch_on_domain = tf.class == TrueClass ? true : false end
switch_on_subdomain=(tf)
click to toggle source
# File lib/sublease.rb, line 106 def switch_on_subdomain=(tf) tenant_model? switch_on_configuration_valid?('subdomain', tf) @switch_on_subdomain = tf.class == TrueClass ? true : false end
switch_on_subdomain_and_domain=(tf)
click to toggle source
# File lib/sublease.rb, line 112 def switch_on_subdomain_and_domain=(tf) tenant_model? switch_on_configuration_valid?('subdomain_and_domain', tf) @switch_on_subdomain_and_domain = tf.class == TrueClass ? true : false end
tenant_model=(model)
click to toggle source
# File lib/sublease.rb, line 92 def tenant_model=(model) if model.class == String @tenant_model = model.capitalize.constantize else @tenant_model = model end end
Private Class Methods
switch_on_configuration_valid?(method, value)
click to toggle source
# File lib/sublease.rb, line 125 def switch_on_configuration_valid?(method, value) case method when 'domain' raise Sublease::ConfigError, 'Option switch_on_domain can not be enabled if switch_on_subdomain_and_domain is enabled.' if (switch_on_subdomain_and_domain == true && value == true) raise Sublease::ConfigError, 'Options switch_on_domain and switch_on_subdomain can not be enabled together. Use switch_on_subdomain_and_domain instead.' if (value == true && switch_on_subdomain == true) when 'subdomain' raise Sublease::ConfigError, 'Option switch_on_subdomain can not be enabled if switch_on_subdomain_and_domain is enabled.' if (switch_on_subdomain_and_domain == true && value == true) raise Sublease::ConfigError, 'Options switch_on_domain and switch_on_subdomain can not be enabled together. Use switch_on_subdomain_and_domain instead.' if (switch_on_domain == true && value == true) when 'subdomain_and_domain' raise Sublease::ConfigError, 'Option switch_on_subdomain_and_domain can not be enabled if either switch_on_domain or switch_on_subdomain is enabled.' if ((switch_on_domain == true && value == true) || (switch_on_subdomain == true && value == true)) else true end end
tenant_model?()
click to toggle source
# File lib/sublease.rb, line 120 def tenant_model? raise Sublease::TenantModelNotSet if tenant_model.nil? true end