blaix / wren

4 stars 0 forks source link

Action call arguments #3

Open blaix opened 9 years ago

blaix commented 9 years ago

Actions can't be completely independent of requests. For example, a request to GET /articles/123 might map a GetArticle action but it would need to know we want article 123.

Things I don't want to do:

My idea is to yield a request object to the resource block in the router. That could be used to pass only the request attributes that the action needs. Something like this:

resource "article_collection", at: "/articles/:article_id" do |request|
  on "GET", call: "get_article", with: request.article_id
end

Which would call (if id is 123): GetArticle.new.call(123). This lets GetArticle exist independent of an HTTP request, which is how I want actions to stay.

blaix commented 9 years ago

Another idea is to just accept a string for the with: argument and assume that is an attribute of the request.