« An alternative theory for "subconsciousness", Part 2 | Main | EDU 2.0 in the News »

Oct 26, 2010

Comments

Damian

Perhaps surprisingly ruby has no means to get parameter names.

Merb (presumably to achieve what you describe here) has 'action-args'. The implementation is quite exciting, one for each of jruby, mri and 1.9.

http://merbivore.com/documentation/1.0.6.1/doc/rdoc/merb-action-args-1.0/index.html

intertwingly.net/blog

I don't believe that Ruby itself provides the necessary function to do this: if you get access to a method, you can determine its "arity" but not the names of arguments.

The closest you could come is something like this:

action :mymethods, [:a, :b] do
end

For bonus points, the action method could define the necessary route.

Graham Glass

According to this, there are a few ways to get method names via reflection:

http://stackoverflow.com/questions/622324/getting-argument-names-in-ruby-reflection

Perhaps this is something new in Ruby 1.9?

Robert W. Oliver II

This might show Rails's heritage from a fed-up PHP developer. Having to set the variables from the param[] array might help prevent against security attacks and trying to chase down order-of-insertion bugs.

The comments to this entry are closed.

Destiny

  • Destiny is my science fiction movie about the future of humanity. It's an epic, similar in breadth and scope to 2001: A Space Odyssey.

    To see the 18 minute video, click on the graphic below.

    Destiny17small

People