Sha256: 66ee3b9cbe08db101b9bf63fa6780c4afbef9a5ff82be72f3b2f91733fa6422b

Contents?: true

Size: 638 Bytes

Versions: 15

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

require 'apartment/elevators/generic'

module Apartment
  module Elevators
    #   Provides a rack based tenant switching solution based on hosts
    #   Uses a hash to find the corresponding tenant name for the host
    #
    class HostHash < Generic
      def initialize(app, hash = {}, processor = nil)
        super app, processor
        @hash = hash
      end

      def parse_tenant_name(request)
        unless @hash.key?(request.host)
          raise TenantNotFound,
                "Cannot find tenant for host #{request.host}"
        end

        @hash[request.host]
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
puzzle-apartment-2.12.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.11.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.10.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.9.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.8.1 lib/apartment/elevators/host_hash.rb
ros-apartment-2.8.1.rc2 lib/apartment/elevators/host_hash.rb
ros-apartment-2.8.1.rc1 lib/apartment/elevators/host_hash.rb
ros-apartment-2.8.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.7.2 lib/apartment/elevators/host_hash.rb
ros-apartment-2.7.1 lib/apartment/elevators/host_hash.rb
ros-apartment-2.7.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.6.1 lib/apartment/elevators/host_hash.rb
ros-apartment-2.6.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.5.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.4.0 lib/apartment/elevators/host_hash.rb