class Sidekiq::WebRoute

Constants

NAMED_SEGMENTS_PATTERN

Attributes

block[RW]
name[RW]
pattern[RW]
request_method[RW]

Public Class Methods

new(request_method, pattern, block) click to toggle source
# File lib/sidekiq/web/router.rb, line 69
def initialize(request_method, pattern, block)
  @request_method = request_method
  @pattern = pattern
  @block = block
end

Public Instance Methods

compile() click to toggle source
# File lib/sidekiq/web/router.rb, line 79
def compile
  if pattern.match(NAMED_SEGMENTS_PATTERN)
    p = pattern.gsub(NAMED_SEGMENTS_PATTERN, '/\1(?<\2>[^$/]+)')

    Regexp.new("\\A#{p}\\Z")
  else
    pattern
  end
end
match(request_method, path) click to toggle source
# File lib/sidekiq/web/router.rb, line 89
def match(request_method, path)
  case matcher
  when String
    {} if path == matcher
  else
    if path_match = path.match(matcher)
      Hash[path_match.names.map(&:to_sym).zip(path_match.captures)]
    end
  end
end
matcher() click to toggle source
# File lib/sidekiq/web/router.rb, line 75
def matcher
  @matcher ||= compile
end