Senior Software Engineer: Love Writing and Reading Software, Taking Entrepreneurial Risks, Teaching Computer Programming & Blogging here or in many other places. I also Love Music and I can call myself a small pianist!
How to Define and Use Class-level Variables While Mixing in Modules
There are sometimes that you might want to use class-level variables in a reusable module. How will you do that? Here is a sample ruby program that does that:
In the above example, we keep a class level Set of symbols (@cached_keys). We want every class that mixes in Cacheable to have its own instance of that Set.