-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop
RequestStore
in favour of ActiveSupport::CurrentAttributes
- Loading branch information
Showing
5 changed files
with
56 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module PaperTrail | ||
module Request | ||
# Thread-isolated attributes for managing the current request. | ||
class CurrentAttributes < ActiveSupport::CurrentAttributes | ||
attribute :enabled | ||
attribute :enabled_for | ||
attribute :controller_info | ||
attribute :whodunnit | ||
attribute :skip_reset | ||
|
||
def enabled_for | ||
super || self.enabled_for = {} | ||
end | ||
|
||
# Overrides ActiveSupport::CurrentAttributes#reset to support skipping. | ||
def reset | ||
return if skip_reset | ||
super | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters