Created
March 27, 2011 06:31
-
-
Save quamen/888982 to your computer and use it in GitHub Desktop.
Module to demonstrate how we can hijack the ActiveResource find method
This file contains hidden or 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
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