Module: Roda::RodaPlugins::OptimizedSegmentMatchers

Defined in:
lib/roda/plugins/optimized_segment_matchers.rb

Overview

The optimized_segment_matchers plugin adds two optimized matcher methods, r.on_segment and r.is_segment. r.on_segment is an optimized version of r.on String that accepts no arguments and yields the next segment if there is a segment. r.is_segment is an optimized version of r.is String that accepts no arguments and yields the next segment only if it is the last segment.

plugin :optimized_segment_matchers

route do |r|
  r.on_segment do |x|
    # matches any segment (e.g. /a, /b, but not /)
    r.is_segment do |y|
      # matches only if final segment (e.g. /a/b, /b/c, but not /c, /c/d/, /c/d/e)
    end
  end
end

Defined Under Namespace

Modules: RequestMethods