Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 35 lines (29 sloc) 0.947 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
require 'caches'

begin
  Kernel.const_get :ActiveRecord
  ActiveRecord::Base.extend Caches
  ActiveRecord::Base.instance_cache_storage Caches::Storage::Class
  ActiveRecord::Base.class_eval do
    include Caches::Helper::PerID

    def self.remove_methods_on_reset?
      true
    end
    
    def self.remove_variables_on_reset?
      true
    end
    
    def self.reset_subclasses #:nodoc:
      nonreloadables = []
      subclasses.each do |klass|
        unless Dependencies.autoloaded? klass
          nonreloadables << klass
          next
        end
        klass.instance_variables.each { |var| klass.send(:remove_instance_variable, var) } if klass.remove_variables_on_reset?
        klass.instance_methods(false).each { |m| klass.send :undef_method, m } if klass.remove_methods_on_reset?
      end
      @@subclasses = {}
      nonreloadables.each { |klass| (@@subclasses[klass.superclass] ||= []) << klass }
    end

  end

rescue
end
Something went wrong with that request. Please try again.