[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Loading, CGI and some aother questions

Gambler Gluck

11/11/2006 8:11:00 PM

Well, configs are mine anyway, so I'm not afraid of injection from those files. But how do I "source" a file? Kernel#load and Kernel#require return boolean and do not seem to affect local scope. Could you please provide a code example?----- Original Message ----The sourcing a .rb file is more flexible, however you risk codeinjection that way. Usual considerations apply.David Vallner ____________________________________________________________________________________Do you Yahoo!?Everyone is raving about the all-new Yahoo! Mail beta.http://new.mail...

2 Answers

Ara.T.Howard

11/11/2006 8:22:00 PM

0

David Vallner

11/11/2006 8:25:00 PM

0

Gambler Gluck wrote:
> Well, configs are mine anyway, so I'm not afraid of injection from those files. But how do I "source" a file? Kernel#load and Kernel#require return boolean and do not seem to affect local scope. Could you please provide a code example?
>

eval / instance_eval / class_eval the contents of the file instead. You
could also do as Rails does in for example config/routes.rb and provide
an API to configure your app in a singleton. (Even is singletons are
slightly evil with respects to unit testing, configuration isn't a
component whose state changes at runtime as part of regular operation -
i.e. only explicitly, not as a business logic side effect, so you can
probably get away with that approach.)

David Vallner