From 766195563469ce8c081a0937974e3cd2bb84f107 Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Fri, 3 Feb 2012 17:57:53 +0200 Subject: AS::Callbacks: :skip_after_callbacks_if_terminated option --- activesupport/CHANGELOG.md | 2 ++ activesupport/lib/active_support/callbacks.rb | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index ad9a12fc9b..c78abdcaee 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 5eaeac2cb3..c84742054a 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. # + # * :skip_after_callbacks_if_terminated - Determines if after callbacks should be terminated + # by the :terminator option. By default after callbacks executed no matter + # if callback chain was terminated or not. + # Option makes sence only when :terminator option is specified. + # # * :rescuable - By default, after filters are not executed if # the given block or a before filter raises an error. By setting this option # to true exception raised by given block is stored and after -- cgit v1.2.3