Class: Apill::Matchers::SubdomainMatcher
- Inherits:
-
Object
- Object
- Apill::Matchers::SubdomainMatcher
- Defined in:
- lib/apill/matchers/subdomain_matcher.rb
Instance Method Summary collapse
-
#initialize(allowed_subdomains: Apill.configuration.allowed_subdomains) ⇒ SubdomainMatcher
constructor
A new instance of SubdomainMatcher.
- #matches?(request) ⇒ Boolean
Constructor Details
#initialize(allowed_subdomains: Apill.configuration.allowed_subdomains) ⇒ SubdomainMatcher
Returns a new instance of SubdomainMatcher.
4 5 6 |
# File 'lib/apill/matchers/subdomain_matcher.rb', line 4 def initialize(allowed_subdomains: Apill.configuration.allowed_subdomains) self.allowed_subdomains = Array(allowed_subdomains) end |
Instance Method Details
#matches?(request) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/apill/matchers/subdomain_matcher.rb', line 8 def matches?(request) request_subdomain = request['HTTP_HOST'][/\A([a-z\-]+)/i, 1] allowed_subdomains.include? request_subdomain end |