wycats / merb

master merb branch

This URL has Read+Write access

wycats (author)
Tue Nov 25 09:57:42 -0800 2008
commit  faa1e1fbbed7e97aa610e475ab7020db125f2287
tree    f9ed4b536c878a8beebac9ce451f106b5fe6bd47
parent  83860887996c8df7b5d93b10ca3c9d84aaae0c82
merb / merb-action-args
name age message
..
file LICENSE Loading commit data...
file README
file Rakefile
file TODO
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.