diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-05-25 18:05:58 +0200 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-05-25 18:09:12 +0200 |
commit | 10085114ce7ec6bc967fa701c49ef218f666efb5 (patch) | |
tree | 865841b3f014024f5f8b8cc44462aca699b6eff1 /activesupport/lib | |
parent | 9cda410d818353a5c27cbd5df754f1d1e290927d (diff) | |
download | rails-10085114ce7ec6bc967fa701c49ef218f666efb5.tar.gz rails-10085114ce7ec6bc967fa701c49ef218f666efb5.tar.bz2 rails-10085114ce7ec6bc967fa701c49ef218f666efb5.zip |
Make Filter#filter work with around filters
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/new_callbacks.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb index f8108780f1..039d0fa658 100644 --- a/activesupport/lib/active_support/new_callbacks.rb +++ b/activesupport/lib/active_support/new_callbacks.rb @@ -298,11 +298,23 @@ module ActiveSupport kind, name = @kind, @name @klass.send(:define_method, "#{method_name}_object") { filter } - @klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 - def #{method_name}(&blk) - #{method_name}_object.send("#{kind}_#{name}", self, &blk) - end - RUBY_EVAL + if kind == :around + @klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def #{method_name}(&blk) + if :#{kind} == :around && #{method_name}_object.respond_to?(:filter) + #{method_name}_object.send("filter", self, &blk) + else + #{method_name}_object.send("#{kind}_#{name}", self, &blk) + end + end + RUBY_EVAL + else + @klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def #{method_name}(&blk) + #{method_name}_object.send("#{kind}_#{name}", self, &blk) + end + RUBY_EVAL + end method_name end end |