class Rack::BearerAuth::MatchPattern::Path

Public Instance Methods

match?(path) click to toggle source
# File lib/rack/bearer_auth/match_pattern.rb, line 50
def match?(path)
  _match?(self.pattern, path)
end

Private Instance Methods

_match?(path_pattern, path_value) click to toggle source
# File lib/rack/bearer_auth/match_pattern.rb, line 56
def _match?(path_pattern, path_value) # rubocop:disable Metrics/MethodLength
  case path_pattern
  when nil
    true
  when String
    path_pattern == path_value
  when Regexp
    !(path_pattern =~ path_value).nil?
  when Proc
    path_pattern.call(path_value)
  when Array
    path_pattern.any? { |pattern| _match?(pattern, path_value) }
  else
    raise "Unsupported path pattern"
  end
end