<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,14 +5,14 @@ require 'rake/rdoctask'
 desc 'Default: run unit tests.'
 task :default =&gt; :test
 
-desc 'Test the has_cached_value plugin.'
+desc 'Test the cached_values plugin.'
 Rake::TestTask.new(:test) do |t|
   t.libs &lt;&lt; 'lib'
   t.pattern = 'test/**/*_test.rb'
   t.verbose = true
 end
 
-desc 'Generate documentation for the has_cached_value plugin.'
+desc 'Generate documentation for the cached_values plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'rdoc'
   rdoc.title    = 'HasCachedValue'</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,2 @@
-require 'has_cached_value'
+require 'cached_values'
 ActiveRecord::Base.send :include, HasCachedValueExtension</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
-module HasCachedValueExtension # :nodoc:
+module CachedValues # :nodoc:
   def self.included(base)
     base.extend(ClassMethods)
   end
   module ClassMethods
     # USAGE:
     #  
-    # a very simple case in which has_cached_value works just like the .count method on a has_many association:
+    # a very simple case in which cached_values works just like the .count method on a has_many association:
     #   
     #   class Company &lt; ActiveRecord::Base
     #     caches_value :total_employees, :sql =&gt; 'select count(*) from employees where company_id = #{id}'
@@ -35,36 +35,36 @@ module HasCachedValueExtension # :nodoc:
     #
     
     def caches_value(association_id, options = {})
-      reflection = create_has_cached_value_reflection(association_id, options)
+      reflection = create_cached_value_reflection(association_id, options)
 
-      configure_dependency_for_has_cached_value(reflection)
+      configure_dependency_for_cached_value(reflection)
 
       reflection.options[:counter_cache] = reflection.options.delete(:cache) if reflection.options[:cache]
       reflection.options[:counter_cache] ||= reflection.name unless false == reflection.options[:counter_cache]
 
-      association_accessor_method(reflection, ActiveRecord::Associations::HasCachedValueAssociation)
+      association_accessor_method(reflection, ActiveRecord::CachedValue)
     end
 
     private
     
-      def configure_dependency_for_has_cached_value(reflection)
+      def configure_dependency_for_cached_value(reflection)
         if reflection.options[:counter_cache] &amp;&amp; reflection.options[:cache]
-          raise ArgumentError, &quot;:cache is an alias for :counter_cache, don't use both options for has_cached_value in #{self.name}&quot;
+          raise ArgumentError, &quot;:cache is an alias for :counter_cache, don't use both options for caches_value in #{self.name}&quot;
         end
       
         if !reflection.options[:sql] &amp;&amp; !reflection.options[:eval]
-          raise ArgumentError, &quot;You must specify either the :eval or :sql options for has_cached_value in #{self.name}&quot;
+          raise ArgumentError, &quot;You must specify either the :eval or :sql options for caches_value in #{self.name}&quot;
         end
       
         if reflection.options[:sql] &amp;&amp; reflection.options[:eval]
-          raise ArgumentError, &quot;:eval and :sql are mutually exclusive options.  You may specify one or the other for has_cached_value in #{self.name}&quot;
+          raise ArgumentError, &quot;:eval and :sql are mutually exclusive options.  You may specify one or the other for caches_value in #{self.name}&quot;
         end
       end
     
-      def create_has_cached_value_reflection(association_id, options)
+      def create_cached_value_reflection(association_id, options)
         options.assert_valid_keys(:sql, :eval, :cache, :counter_cache)
         
-        reflection = ActiveRecord::Reflection::AssociationReflection.new(:has_cached_value, association_id, options, self)
+        reflection = ActiveRecord::Reflection::MacroReflection.new(:cached_value, association_id, options, self)
         write_inheritable_hash :reflections, association_id =&gt; reflection
         reflection
       end
@@ -86,114 +86,112 @@ module HasCachedValueExtension # :nodoc:
 end
 
 module ActiveRecord
-  module Associations
-    class HasCachedValueAssociation
-      attr_reader :reflection
-      instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$)/ }
+  class CachedValue
+    attr_reader :reflection
+    instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$)/ }
 
-      def initialize(owner, reflection)
-        @owner, @reflection = owner, reflection
-        reset
+    def initialize(owner, reflection)
+      @owner, @reflection = owner, reflection
+      reset
+    end
+    
+    def reset
+      @target = nil
+      @loaded = false
+    end
+
+    def load
+      reset
+      load_target
+    end
+
+    def reload
+      reset
+      clear_cache
+      load_target
+    end
+    
+    def clear
+      clear_cache
+      @owner.instance_variable_set(&quot;@#{@reflection.name}&quot;, nil)
+    end
+
+    def loaded?
+      @loaded
+    end
+    
+    def loaded
+      @loaded = true
+    end
+    
+    def target
+      @target
+    end
+
+    protected
+    
+      def find_target_by_eval
+        if @reflection.options[:eval].is_a?(String)
+          eval(@reflection.options[:eval], @owner.send(:binding))
+        elsif @reflection.options[:eval].is_a?(Proc)
+          @reflection.options[:eval].call(@owner)
+        else
+          raise ArgumentError.new(&quot;The :eval option on a cached_values must be either a String or a Proc&quot;)
+        end
       end
       
-      def reset
-        @target = nil
-        @loaded = false
+      def find_target_by_sql
+        @owner.class.count_by_sql(sanitize_sql(interpolate_sql(@reflection.options[:sql])))
       end
-
-      def load
-        reset
-        load_target
+      
+      def find_target_from_cache
+        @owner.send(:read_attribute, @reflection.counter_cache_column) if has_cached_counter?
       end
 
-      def reload
-        reset
-        clear_cache
-        load_target
+      def find_target
+        target = find_target_from_cache
+        unless target
+          target ||= @reflection.options[:sql] ? find_target_by_sql : find_target_by_eval
+          update_cache(target)
+        end
+        target
       end
       
-      def clear
-        clear_cache
-        @owner.instance_variable_set(&quot;@#{@reflection.name}&quot;, nil)
-      end
-
-      def loaded?
-        @loaded
+      def update_cache(value)
+        return unless has_cached_counter?
+        unless @owner.new_record?
+          @owner.class.update_all([&quot;#{@reflection.counter_cache_column} = ?&quot;, value], [&quot;id = ?&quot;, @owner.id])
+        end
+        @owner.send(:write_attribute, @reflection.counter_cache_column, value)
       end
       
-      def loaded
-        @loaded = true
+      def clear_cache
+        update_cache(nil)
       end
       
-      def target
+      def load_target
+        return nil unless defined?(@loaded)
+        @target = find_target unless loaded?
+        @loaded = true
         @target
       end
 
-      protected
+      def has_cached_counter?
+        @reflection.options[:counter_cache] &amp;&amp; @owner.attribute_names.include?(@reflection.options[:counter_cache].to_s)
+      end
       
-        def find_target_by_eval
-          if @reflection.options[:eval].is_a?(String)
-            eval(@reflection.options[:eval], @owner.send(:binding))
-          elsif @reflection.options[:eval].is_a?(Proc)
-            @reflection.options[:eval].call(@owner)
-          else
-            raise ArgumentError.new(&quot;The :eval option on a has_cached_value must be either a String or a Proc&quot;)
-          end
-        end
-        
-        def find_target_by_sql
-          @owner.class.count_by_sql(sanitize_sql(interpolate_sql(@reflection.options[:sql])))
-        end
-        
-        def find_target_from_cache
-          @owner.send(:read_attribute, @reflection.counter_cache_column) if has_cached_counter?
-        end
-
-        def find_target
-          target = find_target_from_cache
-          unless target
-            target ||= @reflection.options[:sql] ? find_target_by_sql : find_target_by_eval
-            update_cache(target)
-          end
-          target
-        end
-        
-        def update_cache(value)
-          return unless has_cached_counter?
-          unless @owner.new_record?
-            @owner.class.update_all([&quot;#{@reflection.counter_cache_column} = ?&quot;, value], [&quot;id = ?&quot;, @owner.id])
-          end
-          @owner.send(:write_attribute, @reflection.counter_cache_column, value)
-        end
-        
-        def clear_cache
-          update_cache(nil)
-        end
-        
-        def load_target
-          return nil unless defined?(@loaded)
-          @target = find_target unless loaded?
-          @loaded = true
-          @target
-        end
-
-        def has_cached_counter?
-          @reflection.options[:counter_cache] &amp;&amp; @owner.attribute_names.include?(@reflection.options[:counter_cache].to_s)
-        end
-        
-        def interpolate_sql(sql, record = nil)
-          @owner.send(:interpolate_sql, sql, record)
-        end
+      def interpolate_sql(sql, record = nil)
+        @owner.send(:interpolate_sql, sql, record)
+      end
 
-        def sanitize_sql(sql)
-          @owner.class.send(:sanitize_sql, sql)
-        end
-        
-        def method_missing(method, *args, &amp;block)
-          if load_target        
-            @target.send(method, *args, &amp;block)
-          end
+      def sanitize_sql(sql)
+        @owner.class.send(:sanitize_sql, sql)
+      end
+      
+      def method_missing(method, *args, &amp;block)
+        if load_target        
+          @target.send(method, *args, &amp;block)
         end
-    end
+      end
   end
 end</diff>
      <filename>lib/cached_values.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
 # desc &quot;Explaining what the task does&quot;
-# task :has_cached_value do
+# task :cached_values do
 #   # Task goes here
 # end</diff>
      <filename>tasks/cached_values_tasks.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6ce2dda5e8e4ad2891951aba389c30ddfafd86fc</id>
    </parent>
  </parents>
  <author>
    <name>studioda</name>
    <email>studioda@7491b73d-821b-0410-9297-ad1f6b5b4194</email>
  </author>
  <url>http://github.com/JackDanger/cached_values/commit/d867d0fe9661dd5af9459899a35afc49d6e2d22b</url>
  <id>d867d0fe9661dd5af9459899a35afc49d6e2d22b</id>
  <committed-date>2007-08-31T08:14:52-07:00</committed-date>
  <authored-date>2007-08-31T08:14:52-07:00</authored-date>
  <message>finished most of the renaming

git-svn-id: http://svn.6brand.com/projects/plugins/cached_values@350 7491b73d-821b-0410-9297-ad1f6b5b4194</message>
  <tree>8433a1041a390945f3c4d7b600baa03336766381</tree>
  <committer>
    <name>studioda</name>
    <email>studioda@7491b73d-821b-0410-9297-ad1f6b5b4194</email>
  </committer>
</commit>
