Optionally pass audited action to conditionals#754
Open
sebastianludwig wants to merge 1 commit intocollectiveidea:mainfrom
Open
Optionally pass audited action to conditionals#754sebastianludwig wants to merge 1 commit intocollectiveidea:mainfrom
sebastianludwig wants to merge 1 commit intocollectiveidea:mainfrom
Conversation
sebastianludwig
commented
Mar 6, 2025
| # end | ||
| # | ||
| # * +require_comment+ - Ensures that audit_comment is supplied before | ||
| # * +comment_required+ - Ensures that audit_comment is supplied before |
Author
There was a problem hiding this comment.
Kind of related documentation fix: The private method is called require_comment, the option is called comment_required.
| return true if condition.blank? | ||
| return condition.call(self) == matching if condition.respond_to?(:call) | ||
| return send(condition) == matching if respond_to?(condition.to_sym, true) | ||
| result = case condition |
Author
There was a problem hiding this comment.
Rewritten in the style of evaluate_max_audits above
| return condition.call(self) == matching if condition.respond_to?(:call) | ||
| return send(condition) == matching if respond_to?(condition.to_sym, true) | ||
| result = case condition | ||
| when Proc then condition.call(self, action) |
Author
There was a problem hiding this comment.
I thought about passing action as Symbol but Audit.action is also a String so it's more consistent this way.
Author
|
It would be easy to also incorporate #697 into this PR, but I'm not sure it's worth it. Using |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I only want to record destructions under some circumstances. The proposed implementation allows users to optionally accept an
actionparameter in their condition method or Proc. I've implemented tests and updated the documentation. Looking forward to your feedback!