Capistrano variables are not really "variables". They use
method_missing to find them, so defined? won't work.
If you want to know if a variable has been set (using -S, -s, or set
()), you have to do something like this:
if variables.include?(:stage)
...
else
...
end
- Jamis
On Dec 20, 2006, at 2:36 AM, jeroen wrote:
Hi,
Suppose I have this in my deploy.rb
if defined? stage
puts "ja"
else
puts "nee"
end
puts stage
cap deploy -S stage=123
output:
nee
123
cap deploy
output:
nee
c:/ruby/lib/ruby/gems/1.8/gems/capistrano-1.2.0/lib/capistrano/
configuration.rb:239:in
`method_missing': undefined local variable or method
`stage' for #<Capistrano::Configuration:0x2c83500> (NameError)
from ./config/deploy.rb:21:in `load'
-------------
I'm confused because both cases print "nee" but in the first case the
value of stage (123) is printed, so it must be defined.
On possible way to deal with it is wrap it in inside a begin/rescue
clause and check for a NameError but that's kinda ugly.
Can somebody explain why defined? doesn't work?
TIA
Jeroen
>
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---