Class: Workarea::BasicAuth::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/workarea/basic_auth/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, *http_methods) ⇒ Path



6
7
8
9
10
11
12
13
14
15
# File 'lib/workarea/basic_auth/path.rb', line 6

def initialize(string, *http_methods)
  path = Regexp.escape(string).gsub('\*', ".*?")
  @regexp = Regexp.new("^#{path}$", true)

  if http_methods && http_methods.first.is_a?(Proc)
    @proc = http_methods.first
  end

  @http_methods = http_methods
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



4
5
6
# File 'lib/workarea/basic_auth/path.rb', line 4

def regexp
  @regexp
end

Instance Method Details

#matches?(request) ⇒ Boolean



17
18
19
# File 'lib/workarea/basic_auth/path.rb', line 17

def matches?(request)
  path_matches?(request) && request_matches?(request)
end