« 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.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name is required. Email address will not be displayed with the comment.)

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