class Apartment::Elevators::HostHash

Provides a rack based tenant switching solution based on hosts Uses a hash to find the corresponding tenant name for the host

Public Class Methods

new(app, hash = {}, processor = nil) click to toggle source
Calls superclass method Apartment::Elevators::Generic::new
# File lib/apartment/elevators/host_hash.rb, line 11
def initialize(app, hash = {}, processor = nil)
  super app, processor
  @hash = hash
end

Public Instance Methods

parse_tenant_name(request) click to toggle source
# 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