Created
December 30, 2010 14:11
-
-
Save gosu-zz/759825 to your computer and use it in GitHub Desktop.
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
>> class Lmao | |
>> def initialize | |
>> @str = "HAHAHAHAHAHHAHAHAH" | |
>> @before_laughing = [] | |
>> end | |
>> | |
?> def self.inherited(base) | |
>> base.extend(Callbacks) | |
>> end | |
>> | |
?> def laughing | |
>> self.class.before_laughing_callbacks.each {|method| send(method) } | |
>> @str | |
>> end | |
>> end | |
=> nil | |
>> | |
?> module Callbacks | |
>> def before_laughing_callbacks(*methods) | |
>> @before_laughing = methods | |
>> end | |
>> end | |
=> nil | |
>> | |
?> class Lol < Lmao | |
>> before_laughing_callbacks :downcase_please | |
>> | |
?> def downcase_please | |
>> @str.downcase! | |
>> end | |
>> end | |
=> nil | |
>> | |
?> a = Lol.new | |
=> #<Lol:0x101f1ee18 @before_laughing=[], @str="HAHAHAHAHAHHAHAHAH"> | |
>> puts a.laughing | |
HAHAHAHAHAHHAHAHAH | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment