I have a \"library\" of objects that I want to load on the fly from a database. Each object comes with its own special functions that are called at specific times depending
what you are doing with it is just fine. However, if i were you, for readability and tidyness, i would rather have the function created outside and simply have it assigned to your object key.
You don't need eval here. Instead do it this way whenever you want access to the stored function -
library.myObj.function()