Class: Apartment::Elevators::Domain

Inherits:
Generic
  • Object
show all
Defined in:
lib/apartment/elevators/domain.rb

Overview

Provides a rack based tenant switching solution based on domain

Assumes that tenant name should match domain
Parses request host for second level domain
eg. example.com       => example
    www.example.bc.ca => example

Instance Method Summary collapse

Methods inherited from Generic

#call, #deprecation_warning, #initialize, #parse_database_name, #parse_method

Constructor Details

This class inherits a constructor from Apartment::Elevators::Generic

Instance Method Details

#parse_tenant_name(request) ⇒ Object



13
14
15
16
17
# File 'lib/apartment/elevators/domain.rb', line 13

def parse_tenant_name(request)
  return nil if request.host.blank?

  request.host.match(/(www\.)?(?<sld>[^.]*)/)["sld"]
end