Class: Apartment::Elevators::HostHash
- Defined in:
- lib/apartment/elevators/host_hash.rb
Overview
Provides a rack based tenant switching solution based on hosts
Uses a hash to find the corresponding tenant name for the host
Instance Method Summary collapse
-
#initialize(app, hash = {}, processor = nil) ⇒ HostHash
constructor
A new instance of HostHash.
- #parse_tenant_name(request) ⇒ Object
Methods inherited from Generic
Constructor Details
#initialize(app, hash = {}, processor = nil) ⇒ HostHash
Returns a new instance of HostHash.
11 12 13 14 |
# File 'lib/apartment/elevators/host_hash.rb', line 11 def initialize(app, hash = {}, processor = nil) super app, processor @hash = hash end |
Instance Method Details
#parse_tenant_name(request) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/apartment/elevators/host_hash.rb', line 16 def parse_tenant_name(request) unless @hash.key?(request.host) raise TenantNotFound, "Cannot find tenant for host #{request.host}" end @hash[request.host] end |