<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -223,20 +223,13 @@ module ScottBarron                   #:nodoc:
         # Wraps ActiveRecord::Base.find to conveniently find all records in
         # a given state.  Options:
         #
-        # * +number+ - This is just :first or :all from ActiveRecord
+        # * +number+ - This is just :first or :all from ActiveRecord +find+
         # * +state+ - The state to find
         # * +args+ - The rest of the args are passed down to ActiveRecord +find+
         def find_in_state(number, state, *args)
-          raise InvalidState unless states.include?(state)
-          
-          options = args.last.is_a?(Hash) ? args.pop : {}
-          if options[:conditions]
-            options[:conditions].first &lt;&lt; &quot; AND #{self.state_column} = ?&quot;
-            options[:conditions] &lt;&lt; state.to_s
-          else
-            options[:conditions] = [&quot;#{self.state_column} = ?&quot;, state.to_s]
+          with_state_scope state do
+            find(number, *args)
           end
-          self.find(number, options)
         end
         
         # Wraps ActiveRecord::Base.count to conveniently count all records in
@@ -244,16 +237,30 @@ module ScottBarron                   #:nodoc:
         #
         # * +state+ - The state to find
         # * +args+ - The rest of the args are passed down to ActiveRecord +find+
-        def count_in_state(state, conditions=nil)
+        def count_in_state(state, *args)
+          with_state_scope state do
+            count(*args)
+          end
+        end
+        
+        # Wraps ActiveRecord::Base.calculate to conveniently calculate all records in
+        # a given state.  Options:
+        #
+        # * +state+ - The state to find
+        # * +args+ - The rest of the args are passed down to ActiveRecord +calculate+
+        def calculate_in_state(state, *args)
+          with_state_scope state do
+            calculate(*args)
+          end
+        end
+        
+        protected
+        def with_state_scope(state)
           raise InvalidState unless states.include?(state)
           
-          if conditions
-            conditions.first &lt;&lt; &quot; AND #{self.state_column} = ?&quot;
-            conditions &lt;&lt; state.to_s
-          else
-            conditions = [&quot;#{self.state_column} = ?&quot;, state.to_s]
+          with_scope :find =&gt; {:conditions =&gt; [&quot;#{table_name}.#{state_column} = ?&quot;, state.to_s]} do
+            yield if block_given?
           end
-          self.count(conditions)
         end
       end
     end</diff>
      <filename>lib/acts_as_state_machine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
 ActiveRecord::Schema.define(:version =&gt; 1) do
-  create_table :conversations do |t|
+  create_table :conversations, :force =&gt; true do |t|
     t.column :state_machine, :string
     t.column :subject,       :string
     t.column :closed,        :boolean
   end
   
-  create_table :people do |t|
+  create_table :people, :force =&gt; true do |t|
     t.column :name, :string
   end
 end</diff>
      <filename>test/schema.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>334d29eb518dffed3c37e27faf1387d8f5c31995</id>
    </parent>
  </parents>
  <author>
    <name>sbarron</name>
    <email>sbarron@a9f67fa3-8408-0410-ad84-b6cefbfd10ac</email>
  </author>
  <url>http://github.com/freels/acts_as_state_machine/commit/64de098b3ef9e865bfa43c52040c9f7677d0886d</url>
  <id>64de098b3ef9e865bfa43c52040c9f7677d0886d</id>
  <committed-date>2006-07-23T12:41:31-07:00</committed-date>
  <authored-date>2006-07-23T12:41:31-07:00</authored-date>
  <message>

git-svn-id: http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk@65 a9f67fa3-8408-0410-ad84-b6cefbfd10ac</message>
  <tree>ff5f19a25a50d6d428a54fda8b8326b20480eb47</tree>
  <committer>
    <name>sbarron</name>
    <email>sbarron@a9f67fa3-8408-0410-ad84-b6cefbfd10ac</email>
  </committer>
</commit>
