A couple things that could help your code:

The with_role block is redundant; run will already run in the context of the 
workflow since you defined it at the task level;

:"#{workflow}" == workflow.to_sym

I would prefer to see the latter and consider the former a code smell. It's 
less declarative and mistake prone. 

Be careful of your ruby quoting; single quotes do not do variable expansion

set :workflow, 'hello world'
'#{workflow}' => #{workflow}
"#{workflow}" => hello world

The declarative way to call a dynamic task would be

update_etc_hosts.send(workflow.to_sym)

Theres no ambiguity of what the above line is trying to accomplish. 

If this is the first time you've seen 'send' then read up on it; ruby is built 
on top of send. All of the method missing stuff and all of the meta programming 
that ruby inspires is all based on the concept of 'message sending'

On Oct 3, 2011, at 1:40 PM, Matt L <darfna...@gmail.com> wrote:

> I am trying to make a task that executes all tasks in a namespace.
> Because the tasks will be defined at execution by an array that
> changes, I need to make this work so that I can call each task of the
> namespace dynamically.
> 
> This is what I mean:
> http://pastie.org/2634167
> 
> ... but there is not valid syntax
> 
> Is there a way to do this or can someone please tell me what the
> appropriate sytax for doing this is?
> 
> -- 
> * You received this message because you are subscribed to the Google Groups 
> "Capistrano" group.
> * To post to this group, send email to capistrano@googlegroups.com
> * To unsubscribe from this group, send email to 
> capistrano+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/capistrano?hl=en

-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to capistrano@googlegroups.com
* To unsubscribe from this group, send email to 
capistrano+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to