Sha256: ba6a06d2923283dd5e47e64a5f73d315deec393ef20e377709653541f8c6e0e2
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Wayfarer module Routing module Matchers class Path attr_reader :path, :route, :peeking, :matcher def initialize(path, route) @path = path @route = route @peeking = false @matcher = Mustermann.new(path, type: "sinatra") end def match(url) route.accept(self) # If the route's branch contains other path matchers in child routes, # match the beginning of the path (peeking), instead of the whole path. !!(if peeking matcher.peek(url.path) else matcher.match(url.path) end) end def params(url) return {} unless match(url) matcher.params(url.path) || {} end def visit(route) return true if route == self.route return true if route.is_a?(TargetRoute) return unless route.matcher.is_a?(self.class) @peeking = true false end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.3 | lib/wayfarer/routing/matchers/path.rb |
wayfarer-0.4.2 | lib/wayfarer/routing/matchers/path.rb |