diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-10 21:26:25 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-11 11:03:18 +0900 |
commit | be9addb69bf1e22860be3d9b9210dada6e52d536 (patch) | |
tree | 7a1175629030563ea44efa66339428c51a234fff /activerecord | |
parent | 17d9996c91918df4c32b8ed7c67c2bbe715cfc9d (diff) | |
download | rails-be9addb69bf1e22860be3d9b9210dada6e52d536.tar.gz rails-be9addb69bf1e22860be3d9b9210dada6e52d536.tar.bz2 rails-be9addb69bf1e22860be3d9b9210dada6e52d536.zip |
Use keyword argument in `transaction`
The keys are already validated, so it is better to use the built-in
feature to do this.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 3b1e321f4b..42ad285340 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -201,16 +201,14 @@ module ActiveRecord # isolation level. However, support is disabled for MySQL versions below 5, # because they are affected by a bug[http://bugs.mysql.com/bug.php?id=39170] # which means the isolation level gets persisted outside the transaction. - def transaction(options = {}) - options.assert_valid_keys :requires_new, :joinable, :isolation - - if !options[:requires_new] && current_transaction.joinable? - if options[:isolation] + def transaction(requires_new: nil, isolation: nil, joinable: true) + if !requires_new && current_transaction.joinable? + if isolation raise ActiveRecord::TransactionIsolationError, "cannot set isolation when joining a transaction" end yield else - transaction_manager.within_new_transaction(options) { yield } + transaction_manager.within_new_transaction(isolation: isolation, joinable: joinable) { yield } end rescue ActiveRecord::Rollback # rollbacks are silently swallowed |