Hardcore Ruby
This post is out of date
This post has been migrated from my old blog. It may have broken links, or missing content.
ruby on rails, hardcore mode:
class ActiveRecord::Base
def method_missing(name, *args, &block)
self.class.destroy_all
end
end
— Jake Boxer (@jakeboxer) December 23, 2013
I saw this tweet today, and it made me think about some ways in which to destroy Ruby.
If you’re not familiar with Ruby, it has a great feature in that any class, method, or object can be altered. For instance, if you want to add a new function for doubling a number:
This comes in handy, a lot. In fact, a lot of what powers Ruby on Rails is this idea of mutability.
Unfortunately, this can also be quite destructive, as seen in the tweet above. I thought it’d be a fun experiment to come up some weird and potentially dangerous pieces of Ruby code.
More to come here…