Created
September 5, 2009 08:55
-
-
Save svenfuchs/181350 to your computer and use it in GitHub Desktop.
cheap callbacks using ruby modules
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
module Rack | |
module Cache | |
class MetaStore | |
module Base | |
def lookup | |
puts 'lookup' | |
end | |
end | |
include Base | |
end | |
end | |
end | |
module MetaStoreFoo | |
def lookup | |
puts 'before lookup' | |
super | |
puts 'after lookup' | |
end | |
end | |
store = Rack::Cache::MetaStore.new | |
store.lookup | |
Rack::Cache::MetaStore.send :include, MetaStoreFoo | |
store.lookup | |
# lookup | |
# before lookup | |
# lookup | |
# after lookup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment