Skip to content

Instantly share code, notes, and snippets.

@gosu-zz
Created December 30, 2010 14:11
Show Gist options
  • Save gosu-zz/759825 to your computer and use it in GitHub Desktop.
Save gosu-zz/759825 to your computer and use it in GitHub Desktop.
>> 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