Permalink
Browse files

Avoid converting :on option to array twice when defining commit/rollb…

…ack callbacks
  • Loading branch information...
1 parent 1c88b36 commit 885f3ae39020e95febfa402f7206f3d69fb29137 @carlosantoniodasilva carlosantoniodasilva committed Jan 15, 2014
Showing with 2 additions and 3 deletions.
  1. +2 −3 activerecord/lib/active_record/transactions.rb
@@ -243,15 +243,14 @@ def after_rollback(*args, &block)
def set_options_for_callbacks!(args)
options = args.last
if options.is_a?(Hash) && options[:on]
- assert_valid_transaction_action(options[:on])
- options[:if] = Array(options[:if])
fire_on = Array(options[:on])
+ assert_valid_transaction_action(fire_on)
+ options[:if] = Array(options[:if])
options[:if] << "transaction_include_any_action?(#{fire_on})"
end
end
def assert_valid_transaction_action(actions)
- actions = Array(actions)
if (actions - ACTIONS).any?
raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS.join(",")}"
end

0 comments on commit 885f3ae

Please sign in to comment.