From: Ezra Zygmuntowicz Date: 2007-08-03T06:37:39+09:00 Subject: Re: binding - how to explain it? On Aug 2, 2007, at 12:27 PM, ara.t.howard wrote: > > On Aug 2, 2007, at 12:54 PM, Giles Bowkett wrote: > >> I think I'll see what happens if I make that change. do the tests >> blow >> up, or is it really that simple? stay tuned for the next exciting >> adventure blah blah blah. > > yeah - it's surely complicated by the fact that rails has overidden > Kernel.load too... i'll be interested to see what happens... > > > a @ http://drawohara.com/ > -- > we can deny everything, except that we have the possibility of > being better. simply reflect on that. > h.h. the 14th dalai lama Rails uses that eval(IO.read(...), binding) on the init.rb of plugins so that you have the config local variable defined so you can use it just like you use config.blah = whatever in the Rails::Initializer block in environment.rb. As far as I know that's the only reason it exists. So when you wrap that call in a method without passing in the binding, you defeat the purpose of this hack. If you did this instead the tests will still pass and the right binding will be used: # Change this: def eval_file_with_binding(file) eval(IO.read(file), binding, file) end # To this: def eval_file_with_binding(file, bind=binding) eval(IO.read(file), bind, file) end Cheers- -- Ezra Zygmuntowicz -- Founder & Ruby Hacker -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)