Module: Roda::RodaPlugins::OptimizedStringMatchers

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

Overview

The optimized_string_matchers plugin adds two optimized matcher methods, r.on_branch and r.is_exactly. r.on_branch is an optimized version of r.on that only accepts a single string, and r.is_exactly is an optimized version of r.is that only accepts a single string.

plugin :optimized_string_matchers

route do |r|
  r.on_branch "x" do
    # matches /x and paths starting with /x/
    r.is_exactly "y" do
      # matches /x/y
    end
  end
end

Note that both of these methods only work with plain strings, not with strings with embedded colons for capturing. Matching will work correctly in such cases, but the captures will not be yielded to the match blocks.

Defined Under Namespace

Modules: RequestMethods

Constant Summary collapse

EMPTY_STRING =
''.freeze