diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-31 10:12:12 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-01-31 10:18:34 +0900 |
commit | 1f5e21bcbce41a5d49998df9ee58c1c875626fd6 (patch) | |
tree | 4bd12ee30fe4da974ab170e6628009756de02f12 /activerecord | |
parent | 5754a29a974d31cab2b4392716b9825a3d910a69 (diff) | |
download | rails-1f5e21bcbce41a5d49998df9ee58c1c875626fd6.tar.gz rails-1f5e21bcbce41a5d49998df9ee58c1c875626fd6.tar.bz2 rails-1f5e21bcbce41a5d49998df9ee58c1c875626fd6.zip |
Remove redundant begin block
We enabled `Style/RedundantBegin` cop at #34764, but it is hard to
detect an offence if returning value put after the block.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/middleware/database_selector/resolver.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/middleware/database_selector/resolver.rb b/activerecord/lib/active_record/middleware/database_selector/resolver.rb index 930ddf900e..27050c9f2d 100644 --- a/activerecord/lib/active_record/middleware/database_selector/resolver.rb +++ b/activerecord/lib/active_record/middleware/database_selector/resolver.rb @@ -64,12 +64,9 @@ module ActiveRecord def write_to_primary(&blk) ActiveRecord::Base.connected_to(role: :writing) do instrumenter.instrument("database_selector.active_record.wrote_to_primary") do - begin - ret = yield - ensure - resolver.update_last_write_timestamp - end - ret + yield + ensure + resolver.update_last_write_timestamp end end end |