earlier i asked if its possible to load a string as code. but now, lets
say i have a config file. a text file with ruby code in it. how can i
load that into my ruby code? but for that matter, everytime it does load
it, can it read as a new object? like lets say the config file consists
of "plugins" and i add one, can ruby pick it up while the app is
running?
earlier i asked if its possible to load a string as code. but now, lets
say i have a config file. a text file with ruby code in it. how can i
load that into my ruby code? but for that matter, everytime it does load
it, can it read as a new object? like lets say the config file consists
of "plugins" and i add one, can ruby pick it up while the app is
running?
You can do that by wrapping the loaded code in a module, and then using that module to access any constants or functions defined in the code. Here's how I do that: