class Innkeeper::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 Innkeeper::Elevators::Generic::new
# File lib/innkeeper/elevators/host_hash.rb, line 9
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/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