<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -85,12 +85,12 @@ module ActiveSupport
 
       def run(object, options = {}, &amp;terminator)
         enumerator = options[:enumerator] || :each
-
+        args = options[:args] || []
         unless block_given?
-          send(enumerator) { |callback| callback.call(object) }
+          send(enumerator) { |callback| callback.call(object, *args) }
         else
           send(enumerator) do |callback|
-            result = callback.call(object)
+            result = callback.call(object, *args)
             break result if terminator.call(result, object)
           end
         end
@@ -167,17 +167,20 @@ module ActiveSupport
 
       private
         def evaluate_method(method, *args, &amp;block)
+          object = args.shift
           case method
             when Symbol
-              object = args.shift
+              args = adjust_for_arity(args, object.method(method).arity)
               object.send(method, *args, &amp;block)
             when String
-              eval(method, args.first.instance_eval { binding })
+              eval(method, object.instance_eval { binding })
             when Proc, Method
-              method.call(*args, &amp;block)
+              args = adjust_for_arity(args, method.arity-1)
+              method.call(object, *args, &amp;block)
             else
               if method.respond_to?(kind)
-                method.send(kind, *args, &amp;block)
+                args = adjust_for_arity(args, method.method(kind).arity-1)
+                method.send(kind, object, *args, &amp;block)
               else
                 raise ArgumentError,
                   &quot;Callbacks must be a symbol denoting the method to call, a string to be evaluated, &quot; +
@@ -185,7 +188,14 @@ module ActiveSupport
               end
             end
         end
-
+        
+        def adjust_for_arity(args, arity)
+          if arity &lt; 0
+            args
+          else
+            args[0...arity]
+          end
+        end
         def should_run_callback?(*args)
           if options[:if]
             evaluate_method(options[:if], *args)</diff>
      <filename>activesupport/lib/active_support/callbacks.rb</filename>
    </modified>
    <modified>
      <diff>@@ -64,6 +64,71 @@ class ConditionalPerson &lt; Record
   end
 end
 
+class ArgumentativePerson &lt; Record
+  before_save :check_no_args, :check_first_arg, :check_first_two_args, :check_all_args, :check_first_and_any_args, :check_any_args
+  
+  def check_no_args
+    history &lt;&lt; [:no]
+  end
+
+  def check_first_arg(a)
+    history &lt;&lt; [:first, a]
+  end
+  
+  def check_first_two_args(a,b)
+    history &lt;&lt; [:first_two, a, b]
+  end
+  
+  def check_all_args(a,b,c,d)
+    history &lt;&lt; [:all, a, b, c, d]
+  end
+
+  def check_first_and_any_args(a, *args)
+    history &lt;&lt; [:first_and_any, a, *args]
+  end
+  
+  def check_any_args(*args)
+    history &lt;&lt; [:any, *args]
+  end
+  
+  before_save &quot;history &lt;&lt; [:string_callback]&quot;
+  
+  before_save { |record|          record.history &lt;&lt; [:no] }
+  before_save { |record, a|       record.history &lt;&lt; [:first, a] }
+  before_save { |record, a,b|     record.history &lt;&lt; [:first_two, a, b] }
+  before_save { |record, a,b,c,d| record.history &lt;&lt; [:all, a, b, c, d] }
+  before_save { |record, a,*args| record.history &lt;&lt; [:first_and_any, a, *args] }
+  before_save { |record, *args|   record.history &lt;&lt; [:any, *args] }
+  
+  class NoArgObserver
+    def before_save(record)
+      record.history &lt;&lt; [:no]
+    end
+  end
+  
+  class TwoArgObserver
+    def before_save(record, a,b)
+      record.history &lt;&lt; [:two, a,b]
+    end
+  end
+  
+  class FirstAndAnyObserver
+    def before_save(record, a, *args)
+      record.history &lt;&lt; [:first_and_any, a,*args]
+    end
+  end
+  
+  before_save NoArgObserver.new
+  before_save TwoArgObserver.new
+  before_save FirstAndAnyObserver.new
+    
+
+  def save
+    run_callbacks(:before_save, :args=&gt;[1,2,3,4])
+    run_callbacks(:after_save)
+  end
+end
+
 class CallbacksTest &lt; Test::Unit::TestCase
   def test_save_person
     person = Person.new
@@ -146,3 +211,29 @@ class CallbackChainTest &lt; Test::Unit::TestCase
     assert_equal [:lettuce, :tomato], @chain.map(&amp;:method)
   end
 end
+
+class CallbackWithArgumentsTest &lt; Test::Unit::TestCase
+  def test_callbaks_with_arguments
+    person = ArgumentativePerson.new
+    assert_equal [], person.history
+    person.save
+    assert_equal [
+      [:no              ],
+      [:first,          1],
+      [:first_two,      1,2],
+      [:all,            1,2,3,4],
+      [:first_and_any,  1,2,3,4],
+      [:any,            1,2,3,4],
+      [:string_callback ],
+      [:no              ],
+      [:first,          1],
+      [:first_two,      1,2],
+      [:all,            1,2,3,4],
+      [:first_and_any,  1,2,3,4],
+      [:any,            1,2,3,4],
+      [:no              ],
+      [:two,            1,2],
+      [:first_and_any,  1,2,3,4],
+    ], person.history    
+  end
+end</diff>
      <filename>activesupport/test/callbacks_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2f4aaed7b3feb3be787a316fab3144c06bb21a27</id>
    </parent>
  </parents>
  <author>
    <name>Ruy Asan</name>
    <email>ruyasan@gmail.com</email>
  </author>
  <url>http://github.com/rubyruy/rails/commit/413aac579562519f2684c1ff9bdb087650991157</url>
  <id>413aac579562519f2684c1ff9bdb087650991157</id>
  <committed-date>2008-07-09T17:13:33-07:00</committed-date>
  <authored-date>2008-07-09T17:13:33-07:00</authored-date>
  <message>Implemented :args option for run_callbacks which will pass the provided arguments onto the callback proc or method, IFF it's arity expects them.</message>
  <tree>064f396f76be2068ffe22bf11597f65f3692d7f6</tree>
  <committer>
    <name>Ruy Asan</name>
    <email>ruyasan@gmail.com</email>
  </committer>
</commit>
