Miss Perl? Ever wished Ruby was more like it? Me neither, but that's no excuse for going nuts and hack together some insane code that Perlifies Ruby.
There's no excuse for using it in production though.
Installation
Add this line to your application's Gemfile:
gem 'bless'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bless
Usage
Using bless is simplicity itself. Or was it idiocy? Nevermind, bless your followers by uttering the following. Preferably followed by a prayer that your code will not be seen by anyone. Ever.
blessed_object = bless(Object.new, String)
blessed_object.instance_of?(String) # => true
Now, the proverbial example usage of bless in Perl would operate in conjunction with the my
keyword. However, implementing support for that proved to be somewhat less than straightforward. To make a long story short, setting a local variable from an eval AND retaining that local variable beyond the scope of the eval is simply not possible in Ruby*.
* Until we come up with the idea of hacking Rubinius into submission. Hopefully we'll never think of that.
Contributing
- Fork it
- Create your feature branch (
git checkout -b I-say-we-take-off-and-nuke-it-from-orbit
) - Commit your changes (
git commit -am 'It is the only way to make sure!'
) - Push to the branch (
git push origin I-say-we-take-off-and-nuke-it-from-orbit
) - Create new Pull Request