Class: Apartment::Elevators::Subdomain
- Defined in:
- lib/apartment/elevators/subdomain.rb
Overview
Provides a rack based tenant switching solution based on subdomains
Assumes that tenant name should match subdomain
Direct Known Subclasses
Class Method Summary collapse
- .excluded_subdomains ⇒ Object
-
.excluded_subdomains=(arg) ⇒ Object
rubocop:disable Style/TrivialAccessors.
Instance Method Summary collapse
-
#parse_tenant_name(request) ⇒ Object
rubocop:enable Style/TrivialAccessors.
Methods inherited from Generic
Constructor Details
This class inherits a constructor from Apartment::Elevators::Generic
Class Method Details
.excluded_subdomains ⇒ Object
12 13 14 |
# File 'lib/apartment/elevators/subdomain.rb', line 12 def self.excluded_subdomains @excluded_subdomains ||= [] end |
.excluded_subdomains=(arg) ⇒ Object
rubocop:disable Style/TrivialAccessors
17 18 19 |
# File 'lib/apartment/elevators/subdomain.rb', line 17 def self.excluded_subdomains=(arg) @excluded_subdomains = arg end |
Instance Method Details
#parse_tenant_name(request) ⇒ Object
rubocop:enable Style/TrivialAccessors
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/apartment/elevators/subdomain.rb', line 22 def parse_tenant_name(request) request_subdomain = subdomain(request.host) # If the domain acquired is set to be excluded, set the tenant to whatever is currently # next in line in the schema search path. tenant = if self.class.excluded_subdomains.include?(request_subdomain) nil else request_subdomain end tenant.presence end |