[LRUG] Getting rid of 'proc'

Paul Battley pbattley at gmail.com
Tue Apr 17 03:39:01 PDT 2007


On 17/04/07, Peter Ferne <subs at petef.com> wrote:
> Having missed the meeting I'm wondering how the discussion went. Is
> there a general presumption against the use of proc? Or is your
> alternative more by way of explanation of how proc works? Or
> something else altogether?

Here's the context: Tabnav lets you use expressions to determine which
tab to highlight, where to link to, etc., but it does so using a proc
rather than a straight block. I believed that 'proc' wasn't really
necessary in there, and we were discussing ways to get rid of it.

Here's an example from
http://blog.seesaw.it/articles/2007/02/01/tabnav-for-rails-1-2:

  add_tab do
    named proc{ "Show: " + @post.title }
    links_to proc{ hash_for_post_path(:id => @post.id) }
    show_if proc{ !@post.nil? && !@post.id.nil? }
  end

It should be possible to streamline it to something like this:

  add_tab do
    named{ "Show: " + @post.title }
    links_to{ hash_for_post_path(:id => @post.id) }
    show_if{ !@post.nil? && !@post.id.nil? }
  end

Paul.



More information about the Chat mailing list