Class: Innkeeper::Elevators::HostHash
- Defined in:
- lib/innkeeper/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.
9 10 11 12 |
# File 'lib/innkeeper/elevators/host_hash.rb', line 9 def initialize(app, hash = {}, processor = nil) super app, processor @hash = hash end |
Instance Method Details
#parse_tenant_name(request) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/innkeeper/elevators/host_hash.rb', line 14 def parse_tenant_name(request) raise TenantNotFound, "Cannot find tenant for host #{request.host}" unless @hash.has_key?(request.host) @hash[request.host] end |