David Vallner
11/11/2006 8:25:00 PM
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