public
Description: master merb branch
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb.git
commit  3e5171265f2cf3e4495fe5824b63e8a3cae79e3c
tree    082b3455504721d7894ed07ada9f0e18ac09007f
parent  063c2574a7ffa41473f802effa92b1a41089593f parent  a319ad0c8480bc10225909d7f97898dfd3989e4f
merb / merb-action-args
name age message
..
file LICENSE Mon Sep 22 22:30:22 -0700 2008 Fix license files in merb-more. [michaelklishin]
file README Wed Feb 06 17:34:05 -0800 2008 Action Args [Yehuda Katz]
file Rakefile Loading commit data...
file TODO Thu Feb 07 00:27:41 -0800 2008 Empty merb-assets structure [Yehuda Katz]
directory lib/
directory spec/
merb-action-args/README
merb-action-args
================

A plugin for the Merb framework that provides support for arguments to actions that 
come in from the query.

==== Basics

{{[
class Foo < Merb::Controller
  def bar(baz)
    bar
  end
end
]}}

Hitting "/foo/bar?baz=bat" will call foo("bat").

Hitting "/foo/bar" will raise a BadRequest (Status 400) error.

==== Defaults

{{[
class Foo < Merb::Controller
  def bar(baz, bat = "hola")
    "#{baz} #{bat}"
  end
end
]}}

Hitting "/foo/bar?baz=bat" will call foo("bat", "hola")

Hitting "/foo/bar?baz=bat&bat=whaa" will call foo("bat", "whaa")

Hitting "/foo/bar" will still raise a BadRequest.

==== Out of order defaults

{{[
class Foo < Merb::Controller
  def bar(one, two = "dos", three = "tres")
    "#{one} #{two} #{three}"
  end
end
]}}

The interesting thing here is that hitting "/foo/bar?one=uno&three=three" will call
foo("uno", "dos", "three"). In other words, the defaults can be in any order, and 
merb-action-args will figure out where to fill in the holes.