Class: Drillbit::Matchers::Subdomain

Inherits:
Object
  • Object
show all
Defined in:
lib/drillbit/matchers/subdomain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allowed_subdomains: Drillbit.configuration.allowed_subdomains, allowed_api_subdomains: Drillbit.configuration.allowed_api_subdomains) ⇒ Subdomain

Returns a new instance of Subdomain.



10
11
12
13
14
15
# File 'lib/drillbit/matchers/subdomain.rb', line 10

def initialize(allowed_subdomains:     Drillbit.configuration.allowed_subdomains,
               allowed_api_subdomains: Drillbit.configuration.allowed_api_subdomains)

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

Instance Attribute Details

#allowed_api_subdomainsObject

Returns the value of attribute allowed_api_subdomains.



6
7
8
# File 'lib/drillbit/matchers/subdomain.rb', line 6

def allowed_api_subdomains
  @allowed_api_subdomains
end

#allowed_subdomainsObject

Returns the value of attribute allowed_subdomains.



6
7
8
# File 'lib/drillbit/matchers/subdomain.rb', line 6

def allowed_subdomains
  @allowed_subdomains
end

#requestObject

Returns the value of attribute request.



6
7
8
# File 'lib/drillbit/matchers/subdomain.rb', line 6

def request
  @request
end

Instance Method Details

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/drillbit/matchers/subdomain.rb', line 17

def matches?(request)
  self.request = Requests::Base.resolve(request)

  allowed_subdomains.include? request.subdomain
end

#matches_api_subdomain?(request) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/drillbit/matchers/subdomain.rb', line 23

def matches_api_subdomain?(request)
  self.request = Requests::Base.resolve(request)

  allowed_api_subdomains.include? request.subdomain
end