Class: Apartment::Elevators::HostHash
- Defined in:
- lib/apartment/elevators/host_hash.rb
Overview
Tenant from hostname -> tenant hash mapping. Raises TenantNotFound when host is not in the hash (explicit mapping; missing = config error).
Instance Method Summary collapse
-
#initialize(app, hash: {}, **_options) ⇒ HostHash
constructor
A new instance of HostHash.
- #parse_tenant_name(request) ⇒ Object
Methods inherited from Generic
Constructor Details
#initialize(app, hash: {}, **_options) ⇒ HostHash
Returns a new instance of HostHash.
10 11 12 13 |
# File 'lib/apartment/elevators/host_hash.rb', line 10 def initialize(app, hash: {}, **) super(app) @hash = hash.freeze end |
Instance Method Details
#parse_tenant_name(request) ⇒ Object
15 16 17 18 19 |
# File 'lib/apartment/elevators/host_hash.rb', line 15 def parse_tenant_name(request) raise(TenantNotFound, request.host) unless @hash.key?(request.host) @hash[request.host] end |