diff options
author | Aaron Pfeifer <aaron.pfeifer@gmail.com> | 2011-03-07 21:07:46 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-03-08 15:01:05 +0800 |
commit | df615f127ece4f712448ae5bd3e993ec378d8f7a (patch) | |
tree | 0aed9c73c7ad0f871db418f5ad91efecc3196c7a /activesupport/lib | |
parent | 1408b942d9c2c131a1cdcab97f49d74ce84dae38 (diff) | |
download | rails-df615f127ece4f712448ae5bd3e993ec378d8f7a.tar.gz rails-df615f127ece4f712448ae5bd3e993ec378d8f7a.tar.bz2 rails-df615f127ece4f712448ae5bd3e993ec378d8f7a.zip |
Allow access to a callback event's return result from around callbacks
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 96ce79e896..b531a094cf 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -225,7 +225,10 @@ module ActiveSupport # end [@compiled_options[0], @filter, @compiled_options[1]].compact.join("\n") when :around - "end" + <<-RUBY_EVAL + value + end + RUBY_EVAL end end @@ -423,7 +426,7 @@ module ActiveSupport # # set_callback :save, :before, :before_meth # set_callback :save, :after, :after_meth, :if => :condition - # set_callback :save, :around, lambda { |r| stuff; yield; stuff } + # set_callback :save, :around, lambda { |r| stuff; result = yield; stuff } # # The second arguments indicates whether the callback is to be run +:before+, # +:after+, or +:around+ the event. If omitted, +:before+ is assumed. This @@ -442,6 +445,9 @@ module ActiveSupport # # Before and around callbacks are called in the order that they are set; after # callbacks are called in the reverse order. + # + # Around callbacks can access the return value from the event, if it + # wasn't halted, from the +yield+ call. # # ===== Options # |