From 2386daabe7f8c979b453010dc0de3e1f6bbf859d Mon Sep 17 00:00:00 2001 From: claudiob Date: Thu, 16 Oct 2014 16:21:24 -0700 Subject: Throw :abort halts default CallbackChains This commit changes arguments and default value of CallbackChain's :terminator option. After this commit, Chains of callbacks defined **without** an explicit `:terminator` option will be halted as soon as a `before_` callback throws `:abort`. Chains of callbacks defined **with** a `:terminator` option will maintain their existing behavior of halting as soon as a `before_` callback matches the terminator's expectation. For instance, ActiveModel's callbacks will still halt the chain when a `before_` callback returns `false`. --- activerecord/lib/active_record/transactions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index de701edca0..95e9a8646e 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -17,7 +17,7 @@ module ActiveRecord included do define_callbacks :commit, :rollback, - terminator: ->(_, result) { result == false }, + terminator: ->(_, result_lambda) { result_lambda.call == false }, scope: [:kind, :name] mattr_accessor :raise_in_transactional_callbacks, instance_writer: false -- cgit v1.2.3