Class: BasicAuth::Matcher
- Inherits:
-
Object
- Object
- BasicAuth::Matcher
- Defined in:
- lib/basic_auth/matcher.rb
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #match? ⇒ Boolean
Constructor Details
#initialize(path, options = {}) ⇒ Matcher
3 4 5 6 |
# File 'lib/basic_auth/matcher.rb', line 3 def initialize(path, ={}) @path, = path, @protect = [:protect] end |
Instance Method Details
#match? ⇒ Boolean
8 9 10 11 12 13 14 |
# File 'lib/basic_auth/matcher.rb', line 8 def match? return true unless @protect # defaults to protect all # If user accidentally sets a string, change to a regexp pattern = @protect.is_a?(String) ? Regexp.new(@protect) : @protect matched = @path =~ pattern !!matched end |