Skip to content

Instantly share code, notes, and snippets.

@svenfuchs
Created September 5, 2009 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svenfuchs/181350 to your computer and use it in GitHub Desktop.
Save svenfuchs/181350 to your computer and use it in GitHub Desktop.
cheap callbacks using ruby modules
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