Class: Simplec::Subdomains

Inherits:
Object
  • Object
show all
Defined in:
app/constraints/simplec/subdomains.rb

Class Method Summary collapse

Class Method Details

.matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/constraints/simplec/subdomains.rb', line 3

def self.matches?(request)
    present = request.subdomain.present?
  not_admin = request.subdomain != 'admin'
   subdomain = Simplec::Subdomain.find_by(name: request.subdomain)

	match = present && not_admin && subdomain

    if match
      Thread.current[:simplec_subdomain] = subdomain
    else
      Rails.logger.info <<-LOG unless match
Simplec Subdomain '#{request.subdomain}' was not found.
ActionDispatch::Request#original_url: #{request.original_url}
'admin' subdomain bypass: #{!not_admin}
LOG
    end

	match
end