aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-02-04 02:53:47 -0800
committerJosé Valim <jose.valim@plataformatec.com.br>2012-02-04 02:53:47 -0800
commitb41ef0a448c025f1f2eef33c28ea565e38491f5c (patch)
tree8a9440bb6c51b8eb6b562d870584b17548c45005 /activesupport
parentd709b124d1815340f4a2229b05362ea37298288f (diff)
parent766195563469ce8c081a0937974e3cd2bb84f107 (diff)
downloadrails-b41ef0a448c025f1f2eef33c28ea565e38491f5c.tar.gz
rails-b41ef0a448c025f1f2eef33c28ea565e38491f5c.tar.bz2
rails-b41ef0a448c025f1f2eef33c28ea565e38491f5c.zip
Merge pull request #4866 from bogdan/terminate_after_callbacks
AS::Callbacks#define_callbacks: add :terminate_after_callbacks option
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md2
-rw-r--r--activesupport/lib/active_support/callbacks.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 4b061cae4a..f3f838ebfd 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* `AS::Callbacks#define_callbacks`: add `:skip_after_callbacks_if_terminated` option.
+
* Add html_escape_once to ERB::Util, and delegate escape_once tag helper to it. *Carlos Antonio da Silva*
* Remove ActiveSupport::TestCase#pending method, use `skip` instead. *Carlos Antonio da Silva*
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index bc6bd55a45..3091a36fa0 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -169,7 +169,7 @@ module ActiveSupport
when :after
<<-RUBY_EVAL
#{code}
- if #{@compiled_options}
+ if #{!chain.config[:skip_after_callbacks_if_terminated] || "!halted"} && #{@compiled_options}
#{@filter}
end
RUBY_EVAL
@@ -528,6 +528,11 @@ module ActiveSupport
# other callbacks are not executed. Defaults to "false", meaning no value
# halts the chain.
#
+ # * <tt>:skip_after_callbacks_if_terminated</tt> - Determines if after callbacks should be terminated
+ # by the <tt>:terminator</tt> option. By default after callbacks executed no matter
+ # if callback chain was terminated or not.
+ # Option makes sence only when <tt>:terminator</tt> option is specified.
+ #
# * <tt>:rescuable</tt> - By default, after filters are not executed if
# the given block or a before filter raises an error. By setting this option
# to <tt>true</tt> exception raised by given block is stored and after