Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify how to attach to a custom deprecator #114

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,22 @@ DEPRECATION_BEHAVIOR="record" bundle exec rspec path/to/file_spec.rb

## Usage without Rails

Without Rails, you'll need to make sure your `ActiveSupport::Deprecation` instances use the [`:notify` behavior](https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D).
Without Rails, you'll need to make sure your `ActiveSupport::Deprecation` instances use the [`:notify` behavior](https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D) and the `attach_to` is the underscored version of the deprecator's `gem_name` (this is how the `:notify` behavior works):

```ruby
# defined in the gem:
MyGem.deprecator = ActiveSupport::Deprecation.new("2.0", "MyGem::Something")

# in the test helper:
MyGem.deprecator.behavior = :notify

DeprecationToolkit::Configuration.configure do |config|
config.attach_to = MyGem.deprecator.gem_name.underscore.tr("/", "_")
# or more simply
# config.attach_to = "my_gem_something"
config.behavior = :notify
end
```

## License

Expand Down
Loading