Created
July 3, 2012 21:10
-
-
Save aberant/3043167 to your computer and use it in GitHub Desktop.
horrible.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this only works in 1.8 | |
module People | |
extend self | |
def self.base | |
Object | |
end | |
end | |
module Muteable | |
def self.append_features(klass) | |
klass.instance_eval "class << klass;" \ | |
"attr_accessor :mute;" \ | |
"end" | |
end | |
end | |
class Bob < People::base | |
include Muteable | |
def speak | |
unless(Bob::mute): method(:puts)[DATA.read] end | |
end | |
end | |
bob = Bob.new | |
bob.speak | |
Bob::mute = true | |
bob.speak | |
__END__ | |
hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment