Syro v2.0.0 Release Notes

Release Date: 2015-12-05 // over 6 years ago
  • 0️⃣ This version adds the default matcher and two new primitives: consume (match and consume a path segment) and capture (match and capture a path segment, then store the value in the inbox). The reason for providing consume and capture has to do with the fact that a framework using Syro can create new matchers, for example it could provide a matcher that behaves like path captures in Cuba.

    Normally, you can capture a path segment and access the value using the inbox:

    on(:post\_id) do res.write inbox[:post\_id]end
    

    A custom Desk could implement the with matcher:

    def with(arg) default { yield(inbox[arg]) } if capture(arg)end
    

    Then, it could be used as follows:

    with(:post\_id) do |post\_id| ...end
    

    🚀 The functionality to yield the capture to the block was included in version 1.0.0, and it was removed in this release because the implementation performed hash lookups in all matches.

    Deck creators can also redefine the on matcher as follows:

    def on(arg) default { yield(inbox[arg]) } if match(arg)end
    

    This version encourages the use of the inbox instead, and encourages framework authors to create a with matcher if they want that behaviour. The code is production ready.