Quantcast
Channel: Virtuous Code » singleton
Browsing latest articles
Browse All 2 View Live

Quickie Objects in Ruby

Sometimes you need a quick object one-off object. Maybe you’re writing a Fake Object that needs to mimic a subset of a real library’s functionality. Ruby provides several facilities which make it easy...

View Article


Determining Singleton Class Status in Ruby

Q: How do you tell if a given class is an ordinary class or a singleton class? A: Test whether the class is the first element in its own ancestor list. class NotASingleton self == ancestors.first #...

View Article

Browsing latest articles
Browse All 2 View Live