Sha256: cb6c5639ca47013744c5abe565814e6ed06029fa112804265e6b38b3785b1275

Contents?: true

Size: 583 Bytes

Versions: 12

Compression:

Stored size: 583 Bytes

Contents

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)
        raise TenantNotFound,
          "Cannot find tenant for host #{request.host}" unless @hash.has_key?(request.host)

        @hash[request.host]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ros-apartment-2.3.0 lib/apartment/elevators/host_hash.rb
ros-apartment-2.3.0.alpha2 lib/apartment/elevators/host_hash.rb
ros-apartment-2.3.0.alpha1 lib/apartment/elevators/host_hash.rb
apartment-2.2.1 lib/apartment/elevators/host_hash.rb
apartment-2.2.0 lib/apartment/elevators/host_hash.rb
apartment-2.1.0 lib/apartment/elevators/host_hash.rb
apartment-2.0.0 lib/apartment/elevators/host_hash.rb
apartment-1.2.0 lib/apartment/elevators/host_hash.rb
apartment-1.1.0 lib/apartment/elevators/host_hash.rb
apartment-1.0.2 lib/apartment/elevators/host_hash.rb
apartment-1.0.1 lib/apartment/elevators/host_hash.rb
apartment-1.0.0 lib/apartment/elevators/host_hash.rb