Make behavior arguments optional #44
Merged
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.
Description:
This PR fixes #23 by making the last 2 arguments for the custom behavior optional.
Before Rails 5.2, the behavior only supported 2 arguments and ActiveSupport would call the behavior with only 2 arguments (then the error
given 2, expected 4
). By making the unused arguments optional the code works fine in older Rails versions.Behaviors in Rails < 5.2: https://github.com/rails/rails/blob/5-1-stable/activesupport/lib/active_support/deprecation/behaviors.rb#L12
Behaviors since Rails >= 5.2: https://github.com/rails/rails/blob/5-2-stable/activesupport/lib/active_support/deprecation/behaviors.rb#L14
I tested this by creating a Rails 5.1.7 project, adding next_rails to track deprecations and manually added a deprecation warning both before and after this change and I can confirm this fixes the issue.
I will abide by the code of conduct.