0

I've been trying to store a persistent instance of a class in my padrino controller, but am having some headaches. I'm currently just storing it as a class variable, but I'm getting warnings that looks like:

warning: class variable access from toplevel

I tried looking up solutions to this online, but they involve class methods such as class_variable_set or class_eval, neither of which the controller has (Though it has the instance equivalents interestingly enough). Am I trying to do something that shouldn't be done? How can I keep a persistent instance of the class? I need to do so b/c the class hits an online DB and caches stuff quite often.

abu
  • 948
  • 1
  • 7
  • 14

1 Answers1

0

So apparently Padrino controllers are not true classes- the class variables I was assigning were getting put on to some really high level class, which is why I was getting warnings. The way I fixed this was by creating a singleton class which stored the class variables and had getters for them.

abu
  • 948
  • 1
  • 7
  • 14