You've got to be careful with this, because if your class undergoes any state change (added functions, changed constants, class variables, etc) the state that your class was in when the alias was instantiated will not reflect the updated changes in your class.
In order to avoid carpal tunnel without sacrificing readability, you can store a lambda in your alias object rather than the actual class. Of course, the lambda contains the class but this assures your alias will call up the latest version of your class.
I put this in my supermanpatches.rb
rails initializer (inside of config/initializers/
) ‡
LAP = lambda { LosAngelesParcel }
Now you can call this using LAP[]
and a freshly minted version of your class will be loaded. (Allowing you to create instances, for example, by l = LAP[].new
)
‡ runs once when rails is loaded & then is pervasive through your app, callable anywhere kind of like a global variable but 'read-only', so to speak.