From 9446bc18d2d7cbd0b8fc78a4e4be12a1bdaa05a4 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 26 Nov 2025 12:25:13 -0500 Subject: [PATCH] Simplify Current.with_account and .without_account Co-authored-by: Jeffrey Hardy --- app/models/current.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/models/current.rb b/app/models/current.rb index 7fb4d7c8e..e40fc3156 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -12,19 +12,11 @@ class Current < ActiveSupport::CurrentAttributes end end - def with_account(value) - @old_account = self.account - self.account = value - yield - ensure - self.account = @old_account + def with_account(value, &block) + with(account: value, &block) end - def without_account - @old_account = self.account - self.account = nil - yield - ensure - self.account = @old_account + def without_account(&block) + with(account: nil, &block) end end