Basic Object
This is just a snippet to use Basic Object in ruby 1.8.7.
Sometimes we need to start from blank state instead of rich ruby object.
Most often this is when we implement a kind of decorator/delegator patten. Ruby 1.9.2+ provides us a special class BasicObject
for this, but if you have to use 1.8.7 - use this gem. It provides (almost) the same BasicObject
class, so you will use the same code for 1.8.7 and 1.9.2.
Installation
In your Gemfile:
gem 'basic_object' unless defined?(BasicObject)
Usage
Inherit from BasicObject
. That's it.