T
Tim Pease
Could someone explain why this code does not work in ruby1.9 and
possibly provide a workaround. The end goal is to be able to pass a
binding to an ERb result method that provides a limited set of
variables to the ERb template evaluation.
obj = Object.new
class << obj
attr_accessor :foo
end
obj.foo = 'the foo method'
eval "puts foo", obj.__send__
binding)
main:Object (NameError)
from a.rb:7:in `eval'
Blessings,
TwP
possibly provide a workaround. The end goal is to be able to pass a
binding to an ERb result method that provides a limited set of
variables to the ERb template evaluation.
cat a.rb
obj = Object.new
class << obj
attr_accessor :foo
end
obj.foo = 'the foo method'
eval "puts foo", obj.__send__
the foo methodruby a.rb
a.rb:7:in `eval': undefined local variable or method `foo' forruby1.9 a.rb
main:Object (NameError)
from a.rb:7:in `eval'
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]from a.rb:7:in ` said:ruby1.9 --version
Blessings,
TwP