I use some Moose objects that I retrieve from Redis. I wrote code that defines the correct classes and loads them on demand. Now I save them in the session, and when they are restored (using the Session mechanism, and not my own Redis search code), it happens that the necessary module is not yet loaded.
After thinking, I realized that this is due to the fact that I continue to restart the Dancer application when testing after making changes to the route handlers, but my session is still valid. In production, this is most likely not to happen. There the modules were loaded at some point, especially because you need to restore the object before placing it in the session.
However, I would like to fix it, so dynamic loading is no longer needed, and I can not face this problem can't call method foo on an undefined value, because the module is not loaded yet. But where would I reasonably put all these uses? There are only a few of them, so you should not download them in advance.
I thought the main .pmfile that used in the file app.plmight make sense. Or maybe himself app.pl, although this seems wrong. Is there any best practice for this?
source
share