-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Unrelated to this PR: Should we have a dedicated primitive for raising deprecations?
Here's what Rails does: https://blog.saeloun.com/2024/11/19/rails-7-1-adds-application-deprecators-method/
# 1) Define a Custom Deprecator: # config/initializers/deprecators.rb Rails.application.deprecators[:user_full_name] = ActiveSupport::Deprecation.new("2.0", "user_full_name") # Here, the custom deprecator :user_full_name is defined for deprecations related to the full_name method, specifying the Rails version (2.0) and a name for context. # 2) Use the Deprecator in Code: class User < ApplicationRecord def full_name Rails.application.deprecators[:user_full_name].warn("The `full_name` method will be removed in the next major release.") end endBenefits:
Encourages defining a target version
Standardizes how it's reported
Allows telemetry to track adoption
Allows silencing those warnings in production use
Allows deduplication of warnings to avoid spamming in the case of a repeated item
Metadata
Metadata
Assignees
Labels
No labels