<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,9 @@
+* Use named_scope in AR persistence layer, if available [Jan De Poorter]
+
 * Incremented version number
+
 * Cleaned up aasm_states_for_select to return the value as a string
+
 * Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
   Allowing for nil values in states for active record
   Only set state to default state before_validation_on_create</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -36,7 +36,19 @@ module AASM
         base.send(:include, AASM::Persistence::ActiveRecordPersistence::InstanceMethods)
         base.send(:include, AASM::Persistence::ActiveRecordPersistence::ReadState) unless base.method_defined?(:aasm_read_state)
         base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteState) unless base.method_defined?(:aasm_write_state)
-        base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence) unless base.method_defined?(:aasm_write_state_without_persistence)        
+        base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence) unless base.method_defined?(:aasm_write_state_without_persistence)
+        
+        if base.respond_to?(:named_scope)
+          base.extend(AASM::Persistence::ActiveRecordPersistence::NamedScopeMethods)
+          
+          base.class_eval do
+            class &lt;&lt; self
+              alias_method :aasm_state_without_named_scope, :aasm_state
+              alias_method :aasm_state, :aasm_state_with_named_scope
+            end
+          end
+        end
+        
         base.before_validation_on_create :aasm_ensure_initial_state
       end
 
@@ -211,6 +223,13 @@ module AASM
           end
         end
       end
+
+      module NamedScopeMethods
+        def aasm_state_with_named_scope name, options = {}
+          aasm_state_without_named_scope name, options
+          self.named_scope name, :conditions =&gt; {self.aasm_column =&gt; name.to_s} unless self.scopes.include?(name)
+        end       
+      end
     end
   end
 end</diff>
      <filename>lib/persistence/active_record_persistence.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>270d9e12440f66f48f01e7f5ac16d4874a6980fd</id>
    </parent>
  </parents>
  <author>
    <name>Scott Barron</name>
    <email>scott@elitists.net</email>
  </author>
  <url>http://github.com/rubyist/aasm/commit/83bbe4d082b40d7fb7334c7fc5efd3bfe9d64ffb</url>
  <id>83bbe4d082b40d7fb7334c7fc5efd3bfe9d64ffb</id>
  <committed-date>2008-05-30T14:23:23-07:00</committed-date>
  <authored-date>2008-05-30T14:23:23-07:00</authored-date>
  <message>Merge in Jan De Poorter's [DefV] named_scope addition to AR persistence layer, with some organizational clean up.</message>
  <tree>014c0ceab66306b08eaec58b756206c6940da456</tree>
  <committer>
    <name>Scott Barron</name>
    <email>scott@elitists.net</email>
  </committer>
</commit>
