Permalink
Browse files

Support Method callbacks

  • Loading branch information...
1 parent 1008511 commit 2f59066470193c6219dfd958fc5d8096a2ddee68 @lifo lifo committed May 26, 2009
Showing with 8 additions and 0 deletions.
  1. +8 −0 activesupport/lib/active_support/new_callbacks.rb
@@ -287,6 +287,14 @@ def _compile_filter(filter)
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}

0 comments on commit 2f59066

Please sign in to comment.