Execute Ruby code stored in database

P

Petr Janda

Hi,
I've got a hypothetical question, and im hoping someone can answer it.
Let's say ive got a MySql server and I store some Ruby code inside a
column/table/database. Is there anyway I can load this data from a Ruby
program and execute the code as if it was a part of the program?

Cheers,
Petr
 
H

hemant

Hi,
I've got a hypothetical question, and im hoping someone can answer it.
Let's say ive got a MySql server and I store some Ruby code inside a
column/table/database. Is there anyway I can load this data from a Ruby
program and execute the code as if it was a part of the program?

One obvious way is to use 'eval'


--
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org
 
J

John Joyce

Hi,
I've got a hypothetical question, and im hoping someone can answer it.
Let's say ive got a MySql server and I store some Ruby code inside a
column/table/database. Is there anyway I can load this data from a
Ruby
program and execute the code as if it was a part of the program?

Cheers,
Petr
There could be a few ways to do this.
One method would be actually loading that text to a string, and the
string having a file name like name. Then use try to "load
that_string.rb"
No idea if that would work.

The method that would work for sure, get data from DB, save it as
a .rb text file, "load" the file. Of course, that's pointless if you
have to do all of that.

If you just want snippets of code, use eval on the snippets loaded
from DB.

Generally speaking, the file system of the OS is going to be faster
than any DB.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top