Simplify Current.with_account and .without_account

Co-authored-by: Jeffrey Hardy <jeff@37signals.com>
This commit is contained in:
Mike Dalessio
2025-11-26 12:25:13 -05:00
parent a9bb534d86
commit 9446bc18d2
+4 -12
View File
@@ -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