Open vlad-pisanov opened 1 year ago
I think this can be proposed to the style guide first. If accepted by the style guide, it could be implemented in RuobCop Rails. So, I'll transfer this issue to the style guide repo.
A PR is welcome!
Related: https://guides.rubyonrails.org/active_record_callbacks.html#conditional-callbacks
I would be interested in how it's used in the wild, say, real-world-rails repo.
With a single predicate - fine, but what is your take on multiple ones, e.g. if: [:fresh?, :exciting?]
?
Model hooks and controller filters that receive
if:
andunless:
lambdas can be written more succinctly using symbols if the lambda consists of a single method call. This cop would enforce either style consistently based on configuration.