aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-05-26 13:09:33 +0200
committerPratik Naik <pratiknaik@gmail.com>2009-05-26 13:09:33 +0200
commit2f59066470193c6219dfd958fc5d8096a2ddee68 (patch)
tree659ff912c25ba4b6601d76946a3f97c025ad3405 /activesupport
parent10085114ce7ec6bc967fa701c49ef218f666efb5 (diff)
downloadrails-2f59066470193c6219dfd958fc5d8096a2ddee68.tar.gz
rails-2f59066470193c6219dfd958fc5d8096a2ddee68.tar.bz2
rails-2f59066470193c6219dfd958fc5d8096a2ddee68.zip
Support Method callbacks
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/new_callbacks.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb
index 039d0fa658..b6cbdbb6b0 100644
--- a/activesupport/lib/active_support/new_callbacks.rb
+++ b/activesupport/lib/active_support/new_callbacks.rb
@@ -287,6 +287,14 @@ module ActiveSupport
when Proc
@klass.send(:define_method, method_name, &filter)
method_name << (filter.arity == 1 ? "(self)" : "")
+ when Method
+ @klass.send(:define_method, "#{method_name}_method") { filter }
+ @klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
+ def #{method_name}(&blk)
+ #{method_name}_method.call(self, &blk)
+ end
+ RUBY_EVAL
+ method_name
when String
@klass.class_eval <<-RUBY_EVAL
def #{method_name}