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
#call, #deprecation_warning, #parse_database_name, #parse_method
Constructor Details
#initialize(app, hash = {}, processor = nil) ⇒ HostHash
Returns a new instance of HostHash.
9 10 11 12 |
# File 'lib/apartment/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/apartment/elevators/host_hash.rb', line 14 def parse_tenant_name(request) raise DatabaseNotFound, "Cannot find tenant for host #{request.host}" unless @hash.has_key?(request.host) @hash[request.host] end |