Sha256: 5dfbd0027d7c4e7256db2ad8f65c36cae8d2507dc2d24741c8fec27e0f015a5d

Contents?: true

Size: 1.82 KB

Versions: 33

Compression:

Stored size: 1.82 KB

Contents

= New Features

* String and Integer class matchers have been added.  The
  String class matches any non-empty segment and yields it as a
  string.  This is the same as the behavior of the symbol matchers,
  but without the duplication.  So instead of:

    r.is "album", :album_name do |album_name|
    end

  you can now do:

    r.is "album", String do |album_name|
    end

  This makes it a bit more intuitive that you want to match
  any string, and avoids the redundancy between the symbol
  name and block argument name.

  The Integer class matches any integer segment (\d+) and yields it
  as an integer:

    r.is "album", Integer do |album_id|
      # does not match "/albums/foo"
      # matches "/albums/1", yielding 1 (not "1")
    end

  Previously, the :d matcher in the symbol_matchers plugin could
  be used to only match integer segments, but it yielded results
  as strings and not integers, so you still needed to convert the
  type manually.  Using Integer is a bit more intuitive than
  using :d, and it handles the type conversion for you.

* A class_matchers plugin has been added for matching additional
  classes, with user-specified regexps and type conversion.  For
  example, if you want to match YYYY-MM-DD segments and yield
  them to the match blocks as ruby Date objects, you can do:

    plugin :class_matchers

    class_matcher(Date, /(\d\d\d\d)-(\d\d)-(\d\d)/) do |y, m, d|
      [Date.new(y.to_i, m.to_i, d.to_i)]
    end

  and then in your routing tree, you can do:

    r.on "posts", Date do |date|
      # does not match "/posts/foo" or "/posts/2017-01"
      # matches "/posts/2017-01-13", yielding Date.new(2017, 1, 13)
    end

= Backwards Compatibility

* If you were using the Integer and String classes as matchers
  before and expected them to always match, you'll need to
  change your code to use true instead.

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
roda-3.28.0 doc/release_notes/2.27.0.txt
roda-3.27.0 doc/release_notes/2.27.0.txt
roda-3.26.0 doc/release_notes/2.27.0.txt
roda-3.25.0 doc/release_notes/2.27.0.txt
roda-3.24.0 doc/release_notes/2.27.0.txt
roda-3.23.0 doc/release_notes/2.27.0.txt
roda-3.22.0 doc/release_notes/2.27.0.txt
roda-3.21.0 doc/release_notes/2.27.0.txt
roda-3.20.0 doc/release_notes/2.27.0.txt
roda-3.19.0 doc/release_notes/2.27.0.txt
roda-3.18.0 doc/release_notes/2.27.0.txt
roda-3.17.0 doc/release_notes/2.27.0.txt
roda-3.16.0 doc/release_notes/2.27.0.txt
roda-3.15.0 doc/release_notes/2.27.0.txt
roda-3.14.1 doc/release_notes/2.27.0.txt
roda-3.14.0 doc/release_notes/2.27.0.txt
roda-3.13.0 doc/release_notes/2.27.0.txt
roda-3.12.0 doc/release_notes/2.27.0.txt
roda-3.11.0 doc/release_notes/2.27.0.txt
roda-3.10.0 doc/release_notes/2.27.0.txt