Sha256: d1e21597835a9b4faa498b4223bf2120e500d2bedb81b0f547252c8df8c863ba
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 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") # TODO: Add type constant 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.6 | lib/wayfarer/routing/matchers/path.rb |
wayfarer-0.4.5 | lib/wayfarer/routing/matchers/path.rb |
wayfarer-0.4.4 | lib/wayfarer/routing/matchers/path.rb |