<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/constant_cache/core_ext.rb</filename>
    </added>
    <added>
      <filename>spec/examples/constant_cache/core_ext_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,3 @@
 pkg
 coverage
+doc</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,9 @@
+== 0.0.2 2009-04-??
+
+* Enhancements
+  * Better documentation
+  * Modify String class directly instead of using a mix-in
+
 == 0.0.1 2008-04-08
 
 * 1 major enhancement:</diff>
      <filename>HISTORY</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
-ConstantCache
-===============
+= Constant Cache
 
 When your database has tables that store lookup data, there is a tendency 
 to provide those values as constants in the model.  If you have an
@@ -21,21 +20,19 @@ The constants are stored as integer values and need to match up exactly
 with the data that's in the table (not necessarily a bad thing), but this
 solution forces you to write code like this:
 
-Account.new(:username =&gt; 'preagan', :status =&gt; AccountStatus.find(AccountStatus::PENDING))
+  Account.new(:username =&gt; 'preagan', :status =&gt; AccountStatus.find(AccountStatus::PENDING))
 
 This requires multiple calls to find and obfuscates the code a bit.  Since classes
 in Ruby are executable code, we can cache the objects from the database at runtime
 and use them in your application.
 
-Installation
-============
+== Installation
 
 This code is packaged as a gem, so simply use the `gem` command to install:
 
   gem install constant_cache
 
-Example
-=======
+== Example
 
 &quot;Out of the box,&quot; the constant_cache gem assumes that you want to use the 'name' column to generate
 constants from a column called 'name' in your database table.  Assuming this schema:
@@ -72,4 +69,9 @@ well:
     caches_constants :limit =&gt; 16
   end
 
-Copyright (c) 2007 Patrick Reagan of Viget Labs (patrick.reagan@viget.com), released under the MIT license
+== Acknowlegements
+
+Thanks to Dave Thomas for inspiring me to write this during his Metaprogramming talk at a Rails Edge 
+conference in early 2007.
+
+Copyright (c) 2007 Patrick Reagan of Viget Labs (mailto:patrick.reagan@viget.com), released under the MIT license</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -26,8 +26,7 @@ spec = Gem::Specification.new do |s|
   s.add_dependency('activesupport', '&gt;= 2.0.2')
   
   s.require_path = 'lib'
-  s.autorequire = GEM
-  s.files = %w(MIT-LICENSE README Rakefile HISTORY) + Dir.glob(&quot;{lib,spec}/**/*&quot;)
+  s.files = %w(MIT-LICENSE README  Rakefile HISTORY) + Dir.glob(&quot;{lib,spec}/**/*&quot;)
 end
 
 Rake::GemPackageTask.new(spec) do |pkg|</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,5 @@
-require 'constant_cache/format'
+require 'constant_cache/core_ext'
 require 'constant_cache/cache_methods'
 
-String.send(:include, ConstantCache::Format)
 ActiveRecord::Base.send(:extend, ConstantCache::CacheMethods::ClassMethods)
 ActiveRecord::Base.send(:include, ConstantCache::CacheMethods::InstanceMethods)
\ No newline at end of file</diff>
      <filename>lib/constant_cache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,48 @@
 module ConstantCache
+
+  CHARACTER_LIMIT = 64
   
+  # 
+  # Generated constant conflicts with an existing constant
+  #
   class DuplicateConstantError &lt; StandardError; end
-  class InvalidLimitError &lt; StandardError; end
+  class InvalidLimitError &lt; StandardError #:nodoc:
+  end
   
-  module CacheMethods
+  module CacheMethods #:nodoc:
 
     module ClassMethods
+      
+      #
+      # The caches_constants method is the core of the functionality behind this mix-in.  It provides
+      # a simple interface to cache the data in the corresponding table as constants on the model:
+      #
+      #   class Status
+      #     caches_constants
+      #   end
+      # 
+      # It makes certain assumptions about your schema: the constant created is based off of a &lt;tt&gt;name&lt;/tt&gt;
+      # column in the database and long names are truncated to ConstantCache::CHARACTER_LIMIT characters before 
+      # being set as constants. If there is a 'Pending' status in the database, you will now have a 
+      # Status::PENDING constant that points to an instance of ActiveRecord.
+      #
+      # Beyond the basics, some configuration is allowed. You can change both the column that is used to generate
+      # the constant and the truncation length:
+      #
+      #   class State
+      #     caches_constants :key =&gt; :abbreviation, :limit =&gt; 2
+      #   end
+      #
+      # This will use the &lt;tt&gt;abbreviation&lt;/tt&gt; column to generate constants and will truncate constant names to 2 
+      # characters at the maximum.
+      #
+      # Note: In the event that a generated constant conflicts with an existing constant, a 
+      # ConstantCache::DuplicateConstantError is raised.
+      #
       def caches_constants(additional_options = {})
         cattr_accessor :cache_options
 
-        self.cache_options = {:key =&gt; :name, :limit =&gt; 64}.merge(additional_options)
+        self.cache_options = {:key =&gt; :name, :limit =&gt; ConstantCache::CHARACTER_LIMIT}.merge(additional_options)
         
         raise ConstantCache::InvalidLimitError, &quot;Limit of #{self.cache_options[:limit]} is invalid&quot; if self.cache_options[:limit] &lt; 1        
         find(:all).each {|model| model.set_instance_as_constant }
@@ -18,16 +51,23 @@ module ConstantCache
 
     module InstanceMethods
 
-      def constant_name
+      def constant_name #:nodoc:
         constant_name = self.send(self.class.cache_options[:key].to_sym).constant_name
         constant_name = constant_name[0, self.class.cache_options[:limit]] unless constant_name.blank?
         constant_name
       end
+      private :constant_name
 
+      # 
+      # Create a constant on the class that pointing to an instance
+      #
       def set_instance_as_constant
         const = constant_name
         if !const.blank?
-          raise ConstantCache::DuplicateConstantError, &quot;Constant #{self.class.to_s}::#{const} has already been defined&quot; if self.class.const_defined?(const)
+          if self.class.const_defined?(const)
+            message = &quot;Constant #{self.class.to_s}::#{const} has already been defined&quot;
+            raise ConstantCache::DuplicateConstantError, message
+          end
           self.class.const_set(const, self) if !const.blank?
         end
       end</diff>
      <filename>lib/constant_cache/cache_methods.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,9 @@
 module ConstantCache
   
-  module VERSION
+  module VERSION  #:nodoc:
     MAJOR = 0
     MINOR = 0
-    TINY  = 1
+    TINY  = 2
     
     STRING = [MAJOR, MINOR, TINY].join('.')
   end</diff>
      <filename>lib/constant_cache/version.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,6 @@ require 'mocha'
 require 'activesupport'
 require 'activerecord'
 
-
-
 lib_dir = File.join(File.dirname(__FILE__), %w(.. lib constant_cache))
 
 Dir.glob(&quot;#{lib_dir}/*.rb&quot;).each {|file| require file }
@@ -27,7 +25,6 @@ end
 Spec::Runner.configuration.mock_with :mocha
 Spec::Runner.configuration.include ConstantCache::SpecHelper
 
-String.send(:include, ConstantCache::Format)
 ActiveRecord::Base.send(:include, ConstantCache::CacheMethods::InstanceMethods)
 ActiveRecord::Base.send(:extend, ConstantCache::CacheMethods::ClassMethods)
 </diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/constant_cache/format.rb</filename>
    </removed>
    <removed>
      <filename>spec/examples/constant_cache/format_spec.rb</filename>
    </removed>
    <removed>
      <filename>test_helper.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>763901ee6af5f0c5d64d7ec35e41c6a0825ab9ba</id>
    </parent>
  </parents>
  <author>
    <name>Patrick Reagan</name>
    <email>patrick.reagan@viget.com</email>
  </author>
  <url>http://github.com/vigetlabs/constant_cache/commit/da8ecd91d84250328d72035562525d61e1c1ea5c</url>
  <id>da8ecd91d84250328d72035562525d61e1c1ea5c</id>
  <committed-date>2008-04-14T22:41:42-07:00</committed-date>
  <authored-date>2008-04-14T22:41:42-07:00</authored-date>
  <message>Improved documentation
Add String#constant_name directly</message>
  <tree>d3fa4929fd1d1aa825084555bd043e71e5483e83</tree>
  <committer>
    <name>Patrick Reagan</name>
    <email>patrick.reagan@viget.com</email>
  </committer>
</commit>
