Sha256: 392a407910fa1123da88771488cb0af86c111bb8dbbabfe16f67a45c92e6ae2a

Contents?: true

Size: 495 Bytes

Versions: 10

Compression:

Stored size: 495 Bytes

Contents

module Apartment
  module Elevators
    #   Provides a rack based db switching solution based on domain
    #   Assumes that database name should match domain
    #   Parses request host for second level domain
    #   eg. example.com       => example
    #       www.example.bc.ca => example
    #
    class Domain < Generic

      def parse_database_name(request)
        return nil if request.host.blank?

        request.host.match(/(www.)?(?<sld>[^.]*)/)["sld"]
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
apartment-0.21.1 lib/apartment/elevators/domain.rb
apartment-0.21.0 lib/apartment/elevators/domain.rb
apartment-0.20.0 lib/apartment/elevators/domain.rb
apartment-0.19.0 lib/apartment/elevators/domain.rb
apartment-0.18.0 lib/apartment/elevators/domain.rb
apartment-0.17.3 lib/apartment/elevators/domain.rb
apartment-0.17.2 lib/apartment/elevators/domain.rb
apartment-0.17.1 lib/apartment/elevators/domain.rb
apartment-0.17.0 lib/apartment/elevators/domain.rb
apartment-0.16.0 lib/apartment/elevators/domain.rb