I’ve checked off another roadmap item for path-to, namely positional parameters. This makes its metadata-driven client APIs feel even more natural.
Now, when indexing collection resources such as those seen in the Rails example, expressions such as
app.users['user_id' => 'dojo']
can be written
app.users['dojo']
which is quite a lot neater! This style can still be mixed with hash style parameters, such as
app.users['dojo', {'format' => 'json'}]
or
app.users['dojo']['format' => 'json']
In the Delicious API example,
delicious.posts['tag' => 'ruby']
can be written
delicious.posts('ruby')
The square brackets become round brackets in this case as the metadata doesn’t model posts as a collection - it’s just a resource that may take a number of optional parameters, the first of which is the tag name. It took me a few moments to get used to this distinction, but I’m happy now that this gives a more obvious mapping to the underlying API.
Tags: described_routes, path-to, rails, rest, ruby