#36 new
Matt Todd

Meaningful Action Params

Reported by Matt Todd | April 30th, 2008 @ 12:29 AM | in Release 0.6.0

It could be cool to provide similar behavior to Merb's params by having Halcyon parse each controller's actions and get the param list to automatically provide the appropriate values as params from the params.

For example:

class Foos < Application
  def foo(bar, baz)
    # bar and baz are both set to the values
    # in the params hash.
    bar == params[:bar] #=> true
    baz == params[:baz] #=> true
  end
end

Concerning implementation, this should be cached to prevent constant lookup for static content and to reduce response times as much as possible.

Special considerations: caching this data can be tricky in development mode if class reloading is happening and the class is reloaded. (Might be doable if the Halcyon::Controller class has a class variable set when loaded to the last time it was loaded or to a boolean indicating that it was loaded recently; this way, the action signature hash can be recreated.)

Also, for params not found, nil is sufficient since methods can easily contain default values (that we want to trigger), and may not even be settable from routing (like when other actions call it with special params for specialized behavior).

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages