Sha256: d4a098bd6ebebf10e37ad0aba04a9e5872bd9b6828862e5123d096350aa5b9d1

Contents?: true

Size: 585 Bytes

Versions: 9

Compression:

Stored size: 585 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 DatabaseNotFound,
          "Cannot find tenant for host #{request.host}" unless @hash.has_key?(request.host)

        @hash[request.host]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
apartment-0.26.1 lib/apartment/elevators/host_hash.rb
apartment-0.26.0 lib/apartment/elevators/host_hash.rb
apartment-0.25.2 lib/apartment/elevators/host_hash.rb
apartment-0.25.1 lib/apartment/elevators/host_hash.rb
apartment-0.25.0 lib/apartment/elevators/host_hash.rb
apartment-0.24.3 lib/apartment/elevators/host_hash.rb
apartment-0.24.2 lib/apartment/elevators/host_hash.rb
apartment-0.24.1 lib/apartment/elevators/host_hash.rb
apartment-0.24.0 lib/apartment/elevators/host_hash.rb