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
djwonk (author)
Mon May 05 14:43:51 -0700 2008
commit  825d94f27ab3448d76f8f37bf16cc8e13ae06b3c
tree    3cca05589d82cac51735225e35f627b746c98b2b
parent  48fa415a891b00881eda2e14d05020b01e04183e
merb-more / merb-action-args
name age message
..
file LICENSE Sun Feb 10 06:34:47 -0800 2008 [merb-parts] A first attempt at merb part contr... [hassox]
file README Loading commit data...
file Rakefile
file TODO Wed May 21 20:02:39 -0700 2008 initial merb-jquery sugary sweetness [ivey]
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.