public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
Fri Jul 25 04:42:34 -0700 2008
commit  1666db9ba7b683e6377b3926bc6893a77b32de0e
tree    e50d469e749c4901dc7b251e61e4c1319f8bf8a9
parent  24984703c7261fbd197d9567df8b4fa9e62f8ba8
merb-more / merb-action-args
name age message
..
file LICENSE Wed Feb 06 17:34:05 -0800 2008 Action Args [Yehuda Katz]
file README Wed Feb 06 17:34:05 -0800 2008 Action Args [Yehuda Katz]
file Rakefile Wed Jun 11 18:37:36 -0700 2008 Fixes action-args for changes in ParseTree and ... [wycats]
file TODO Wed Feb 06 17:34:05 -0800 2008 Action Args [Yehuda Katz]
directory lib/ Wed Jun 11 18:37:36 -0700 2008 Fixes action-args for changes in ParseTree and ... [wycats]
directory spec/ Wed May 14 08:01:52 -0700 2008 ActionArgs can now eval to false [adelcambre]
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.