<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1 @@
-ActiveRecord::Base.send :extend, Technoweenie::ActiveRecordContext
\ No newline at end of file
+ActiveRecord::Base.send :include, Technoweenie::ActiveRecordContext
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,67 +1,77 @@
 module Technoweenie
   module ActiveRecordContext
-    def self.extended(base)
-      class &lt;&lt; base
-        alias_method_chain :find_every, :context
-        alias_method_chain :find_one,   :context
-      end
+    def self.included(base)
+      base.extend ClassMethods
+      base.alias_method_chain :reload, :context
+      base.cattr_accessor :context_cache
     end
-    
-    mattr_accessor :log_context_activity
-    mattr_reader :context_cache
 
-    # Preloads the record from the given array of IDs.  The ids should all be the same type.
-    # You can pass an array of active record models if that model belongs to the current one.
-    #
-    #   users = User.find :all
-    #   Avatar.prefetch users # performs this automatically: users.collect { |user| user.avatar_id }
-    #
-    def prefetch(ids)
-      return [] if ids.blank?
-      initial = ids.first
-      ids = ids.collect { |record| record.send(prefetch_default) } if initial.respond_to?(prefetch_default)
-      ids.compact!
-      ids.uniq!
-      find :all, :conditions =&gt; { :id =&gt; ids }
-    end
-    
-    # defaults to the foreign key of the current model
-    #
-    #   Avatar =&gt; avatar_id
-    def prefetch_default
-      @prefetch_default ||= name.foreign_key
-    end
-
-    def find_every_with_context(options)
-      returning find_every_without_context(options) do |records|
-        store_in_context records
+    module ClassMethods
+      def self.extended(base)
+        class &lt;&lt; base
+          alias_method_chain :find_every, :context
+          alias_method_chain :find_one,   :context
+        end
       end
-    end
-    
-    def find_one_with_context(id, options)
-      record = options[:conditions].nil? &amp;&amp; cached[id.to_i]
-      logger.debug(&quot;[Context] #{record ? :Found : :Missed} #{name} ##{id}&quot;) if log_context_activity
-      record ? record : find_one_without_context(id, options)
-    end
-
-    def cached
-      context_cache ? (context_cache[self.base_class] ||= {}) : {}
-    end
-    
-    def store_in_context(records)
-      return if context_cache.nil?
-      logger.debug &quot;[Context] Storing #{name} records: #{records.collect(&amp;:id).to_sentence}&quot; if log_context_activity
-      records.inject(cached) do |memo, record| 
-        memo.update record.id =&gt; record
+      
+      # Preloads the record from the given array of IDs.  The ids should all be the same type.
+      # You can pass an array of active record models if that model belongs to the current one.
+      #
+      #   users = User.find :all
+      #   Avatar.prefetch users # performs this automatically: users.collect { |user| user.avatar_id }
+      #
+      def prefetch(ids)
+        return [] if ids.blank?
+        initial = ids.first
+        ids = ids.collect { |record| record.send(prefetch_default) } if initial.respond_to?(prefetch_default)
+        ids.compact!
+        ids.uniq!
+        find :all, :conditions =&gt; { :id =&gt; ids }
+      end
+      
+      # defaults to the foreign key of the current model
+      #
+      #   Avatar =&gt; avatar_id
+      def prefetch_default
+        @prefetch_default ||= name.foreign_key
+      end
+      
+      def find_every_with_context(options)
+        returning find_every_without_context(options) do |records|
+          store_in_context records
+        end
+      end
+      
+      def find_one_with_context(id, options)
+        record = options[:conditions].nil? &amp;&amp; cached[id.to_i]
+        logger.debug(&quot;[Context] #{record ? :Found : :Missed} #{name} ##{id}&quot;)
+        record ? record : find_one_without_context(id, options)
+      end
+      
+      def cached
+        context_cache ? (context_cache[self.base_class] ||= {}) : {}
+      end
+      
+      def store_in_context(records)
+        return if context_cache.nil?
+        logger.debug &quot;[Context] Storing #{name} records: #{records.collect(&amp;:id).to_sentence}&quot;
+        records.inject(cached) do |memo, record| 
+          memo.update record.id =&gt; record
+        end
+      end
+      
+      # Enables the context cache inside this block.
+      def with_context
+        self.context_cache = {}
+        yield
+      ensure
+        self.context_cache = nil
       end
     end
     
-    # Enables the context cache inside this block.
-    def with_context
-      @@context_cache = {}
-      yield
-    ensure
-      @@context_cache = nil
+    def reload_with_context(options = nil)
+      self.class.cached[id.to_i] = nil
+      reload_without_context(options)
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/technoweenie/active_record_context.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@ ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite'])
 
 load(File.dirname(__FILE__) + &quot;/schema.rb&quot;)
 
-ActiveRecord::Base.send :extend, Technoweenie::ActiveRecordContext
+ActiveRecord::Base.send :include, Technoweenie::ActiveRecordContext
 
 class Topic &lt; ActiveRecord::Base
 end</diff>
      <filename>test/abstract_unit.rb</filename>
    </modified>
    <modified>
      <diff>@@ -87,4 +87,13 @@ class ActiveRecordContextTest &lt; Test::Unit::TestCase
     Topic.expects(:find).with(:all, :conditions =&gt; {:id =&gt; [@topic.id]})
     Topic.prefetch @posts
   end
+  
+  def test_should_reload_record
+    Post.with_context do
+      @post = Post.find @posts.first.id
+      assert_equal 'normal body', @post.body
+      Post.update_all ['body = ?', 'foo bar']
+      assert_equal 'foo bar', @post.reload.body
+    end
+  end
 end</diff>
      <filename>test/active_record_context_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9fb24fc500d1e617626660449c34cefc58ff7155</id>
    </parent>
  </parents>
  <author>
    <name>technoweenie</name>
    <email>technoweenie@567b1171-46fb-0310-a4c9-b4bef9110e78</email>
  </author>
  <url>http://github.com/technoweenie/active_record_context/commit/53307381cc6ae0ce3a4783ea732570bfaa9fe3c8</url>
  <id>53307381cc6ae0ce3a4783ea732570bfaa9fe3c8</id>
  <committed-date>2007-09-29T11:21:22-07:00</committed-date>
  <authored-date>2007-09-29T11:21:22-07:00</authored-date>
  <message>add support for reload

git-svn-id: http://svn.techno-weenie.net/projects/plugins/active_record_context@2984 567b1171-46fb-0310-a4c9-b4bef9110e78</message>
  <tree>bf4fcd730c1d22abe9a69ab21c9b6a39fbf5a39a</tree>
  <committer>
    <name>technoweenie</name>
    <email>technoweenie@567b1171-46fb-0310-a4c9-b4bef9110e78</email>
  </committer>
</commit>
