Class: Apill::Matchers::SubdomainMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/apill/matchers/subdomain_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(allowed_subdomains: Apill.configuration.allowed_subdomains, allowed_api_subdomains: Apill.configuration.allowed_api_subdomains, request:) ⇒ SubdomainMatcher

Returns a new instance of SubdomainMatcher.



4
5
6
7
8
9
10
11
# File 'lib/apill/matchers/subdomain_matcher.rb', line 4

def initialize(allowed_subdomains:     Apill.configuration.allowed_subdomains,
               allowed_api_subdomains: Apill.configuration.allowed_api_subdomains,
               request:)

  self.allowed_subdomains     = Array(allowed_subdomains)
  self.allowed_api_subdomains = Array(allowed_api_subdomains)
  self.request                = request
end

Instance Method Details

#matches?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/apill/matchers/subdomain_matcher.rb', line 13

def matches?
  allowed_subdomains.include? request_subdomain
end

#matches_api_subdomain?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/apill/matchers/subdomain_matcher.rb', line 17

def matches_api_subdomain?
  allowed_api_subdomains.include? request_subdomain
end