<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,6 @@
 == master
 
+* Add support for looking up enumerators by their symbol equivalent
 * Fix incompatibility with Ruby 1.9
 * Fix equality / xml serialization not working for non-string enumerators
 * Improve compatibility with the stable branch of Rails 2.3 [Michael Schuerig]</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -125,7 +125,7 @@ module EnumerateBy
     #   Color.find_by_enumerator('red')     # =&gt; #&lt;Color id: 1, name: &quot;red&quot;&gt;
     #   Color.find_by_enumerator('invalid') # =&gt; nil
     def find_by_enumerator(enumerator)
-      first(:conditions =&gt; {enumerator_attribute =&gt; enumerator})
+      first(:conditions =&gt; {enumerator_attribute =&gt; typecast_enumerator(enumerator)})
     end
     
     # Finds the record that is associated with the given enumerator.  If no
@@ -139,7 +139,7 @@ module EnumerateBy
     # 
     # To avoid raising an exception on invalid enumerators, use +find_by_enumerator+.
     def find_by_enumerator!(enumerator)
-      find_by_enumerator(enumerator) || raise(ActiveRecord::RecordNotFound, &quot;Couldn't find #{name} with #{enumerator_attribute} #{enumerator.inspect}&quot;)
+      find_by_enumerator(enumerator) || raise(ActiveRecord::RecordNotFound, &quot;Couldn't find #{name} with #{enumerator_attribute} #{typecast_enumerator(enumerator).inspect}&quot;)
     end
     alias_method :[], :find_by_enumerator!
     
@@ -150,7 +150,7 @@ module EnumerateBy
     #   Color.find_all_by_enumerator(['red', 'green'])  # =&gt; [#&lt;Color id: 1, name: &quot;red&quot;&gt;, #&lt;Color id: 1, name: &quot;green&quot;&gt;]
     #   Color.find_all_by_enumerator('invalid')         # =&gt; []
     def find_all_by_enumerator(enumerators)
-      all(:conditions =&gt; {enumerator_attribute =&gt; enumerators})
+      all(:conditions =&gt; {enumerator_attribute =&gt; typecast_enumerator(enumerators)})
     end
     
     # Finds records with the given enumerators.  If no record is found for a
@@ -164,8 +164,9 @@ module EnumerateBy
     # 
     # To avoid raising an exception on invalid enumerators, use +find_all_by_enumerator+.
     def find_all_by_enumerator!(enumerators)
+      enumerators = [enumerators].flatten
       records = find_all_by_enumerator(enumerators)
-      missing = [enumerators].flatten - records.map(&amp;:enumerator)
+      missing = enumerators - records.map(&amp;:enumerator)
       missing.empty? ? records : raise(ActiveRecord::RecordNotFound, &quot;Couldn't find #{name} with #{enumerator_attribute}(s) #{missing.map(&amp;:inspect).to_sentence}&quot;)
     end
     
@@ -194,6 +195,20 @@ module EnumerateBy
     ensure
       self.perform_enumerator_caching = old
     end
+    
+    private
+      # Typecasts the given enumerator to its actual value stored in the
+      # database.  This will only convert symbols to strings.  All other values
+      # will remain in the same type.
+      def typecast_enumerator(enumerator)
+        if enumerator.is_a?(Array)
+          enumerator.flatten!
+          enumerator.map! {|value| typecast_enumerator(value)}
+          enumerator
+        else
+          enumerator.is_a?(Symbol) ? enumerator.to_s : enumerator
+        end
+      end
   end
   
   module Bootstrapped</diff>
      <filename>lib/enumerate_by.rb</filename>
    </modified>
    <modified>
      <diff>@@ -129,6 +129,56 @@ class EnumerationWithRecordsTest &lt; ActiveRecord::TestCase
   end
 end
 
+class EnumerationWithSymbolReferencesTest &lt; ActiveRecord::TestCase
+  def setup
+    @red = create_color(:name =&gt; 'red')
+    @green = create_color(:name =&gt; 'green')
+  end
+  
+  def test_should_index_by_enumerator
+    assert_equal @red, Color[:red]
+  end
+  
+  def test_should_allow_finding_by_enumerator
+    assert_equal @red, Color.find_by_enumerator(:red)
+  end
+  
+  def test_should_allow_finding_by_enumerator_with_nil
+    assert_nil Color.find_by_enumerator(nil)
+  end
+  
+  def test_should_find_nothing_if_finding_by_unknown_enumerator
+    assert_nil Color.find_by_enumerator(:invalid)
+  end
+  
+  def test_should_raise_exception_for_invalid_index
+    exception = assert_raise(ActiveRecord::RecordNotFound) {Color[:white]}
+    assert_equal &quot;Couldn't find Color with name \&quot;white\&quot;&quot;, exception.message
+  end
+  
+  def test_should_allow_finding_all_by_enumerator
+    assert_equal [@red, @green], Color.find_all_by_enumerator([:red, :green])
+  end
+  
+  def test_should_allow_finding_all_by_enumerator_with_nil
+    assert_equal [], Color.find_all_by_enumerator(nil)
+  end
+  
+  def test_should_find_nothing_if_finding_all_by_unknown_enumerator
+    assert_equal [], Color.find_all_by_enumerator(:invalid)
+  end
+  
+  def test_should_raise_exception_find_finding_all_by_unknown_enumerator!
+    exception = assert_raise(ActiveRecord::RecordNotFound) { Color.find_all_by_enumerator!(:invalid) }
+    assert_equal &quot;Couldn't find Color with name(s) \&quot;invalid\&quot;&quot;, exception.message
+  end
+  
+  def test_should_raise_exception_if_only_some_found_when_finding_all_by_enumerator!
+    exception = assert_raise(ActiveRecord::RecordNotFound) { Color.find_all_by_enumerator!([:red, :invalid]) }
+    assert_equal &quot;Couldn't find Color with name(s) \&quot;invalid\&quot;&quot;, exception.message
+  end
+end
+
 class EnumerationAfterBeingCreatedTest &lt; ActiveRecord::TestCase
   def setup
     @red = create_color(:name =&gt; 'red')
@@ -144,6 +194,10 @@ class EnumerationAfterBeingCreatedTest &lt; ActiveRecord::TestCase
     assert @red == 'red'
   end
   
+  def test_should_allow_equality_with_symbol_enumerator
+    assert @red == :red
+  end
+  
   def test_should_allow_equality_with_record
     assert @red == @red
   end
@@ -164,6 +218,10 @@ class EnumerationAfterBeingCreatedTest &lt; ActiveRecord::TestCase
     assert @red.in?('red')
   end
   
+  def test_should_be_found_in_a_list_of_valid_symbol_names
+    assert @red.in?(:red)
+  end
+  
   def test_should_not_be_found_in_a_list_of_invalid_names
     assert !@red.in?('blue', 'green')
   end</diff>
      <filename>test/unit/enumerate_by_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1b587b11e14d85a6b83335cd5781842c22c62939</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </author>
  <url>http://github.com/pluginaweek/enumerate_by/commit/46b9b1f21c719d66231d47d0eb7d26f458e4e64e</url>
  <id>46b9b1f21c719d66231d47d0eb7d26f458e4e64e</id>
  <committed-date>2009-06-14T17:10:54-07:00</committed-date>
  <authored-date>2009-06-14T17:10:54-07:00</authored-date>
  <message>Add support for looking up enumerators by their symbol equivalent</message>
  <tree>bd2b1af72c3de7d6c95544148d942a05ca90b5c8</tree>
  <committer>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </committer>
</commit>
