Sha256: 86d683f9c08ea36cd6a2533bced8547fc39944df3b151c59f051c628d15e7d26

Contents?: true

Size: 1.26 KB

Versions: 47

Compression:

Stored size: 1.26 KB

Contents

= New Features

* A custom_matchers plugin has been added, which allows using
  arbitrary objects as matchers, as long as the matcher has been
  registered.  You can register matchers using the custom_matcher
  class method, which takes the class of the matcher, and a block
  which is yielded the matcher object.  The block should return
  nil or false if the matcher doesn't match, and any other value
  if the matcher does match.  Example:

    plugin :custom_matchers
    method_segment = Struct.new(:request_method, :next_segment)
    custom_matcher(method_segment) do |matcher|
      # self is the request instance ("r" yielded in the route block below)
      if matcher.request_method == self.request_method
        match(matcher.next_segment)
      end
    end
 
    get_foo = method_segment.new('GET', 'foo')
    post_any = method_segment.new('POST', String)
    route do |r|
      r.on('baz') do
        r.on(get_foo) do
          # GET method, /baz/foo prefix
        end
 
        r.is(post_any) do |seg|
          # for POST /baz/bar, seg is "bar"
        end
      end
 
      r.on('quux') do
        r.is(get_foo) do
          # GET method, /quux/foo route
        end
 
        r.on(post_any) do |seg|
          # for POST /quux/xyz, seg is "xyz"
        end
      end
    end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
roda-3.83.0 doc/release_notes/3.37.0.txt
roda-3.82.0 doc/release_notes/3.37.0.txt
roda-3.81.0 doc/release_notes/3.37.0.txt
roda-3.79.0 doc/release_notes/3.37.0.txt
roda-3.78.0 doc/release_notes/3.37.0.txt
roda-3.77.0 doc/release_notes/3.37.0.txt
roda-3.76.0 doc/release_notes/3.37.0.txt
roda-3.75.0 doc/release_notes/3.37.0.txt
roda-3.74.0 doc/release_notes/3.37.0.txt
roda-3.73.0 doc/release_notes/3.37.0.txt
roda-3.72.0 doc/release_notes/3.37.0.txt
roda-3.71.0 doc/release_notes/3.37.0.txt
roda-3.70.0 doc/release_notes/3.37.0.txt
roda-3.69.0 doc/release_notes/3.37.0.txt
roda-3.68.0 doc/release_notes/3.37.0.txt
roda-3.67.0 doc/release_notes/3.37.0.txt
roda-3.66.0 doc/release_notes/3.37.0.txt
roda-3.65.0 doc/release_notes/3.37.0.txt
roda-3.64.0 doc/release_notes/3.37.0.txt
roda-3.63.0 doc/release_notes/3.37.0.txt