Skip to content

Instantly share code, notes, and snippets.

@quamen
Created March 27, 2011 06:31
Show Gist options
  • Save quamen/888982 to your computer and use it in GitHub Desktop.
Save quamen/888982 to your computer and use it in GitHub Desktop.
Module to demonstrate how we can hijack the ActiveResource find method
require 'active_support/concern'
module CachedResource
extend ActiveSupport::Concern
included do
class << self
alias_method_chain :find, :read_through_cache
end
end
module ClassMethods
def find_with_read_through_cache(*arguments)
puts "I'm hijacking the find method, but not doing anything."
find_without_read_through_cache(*arguments)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment