ActiveSupport::Deprecation
Active Support Deprecation
Deprecation specifies the API used by Rails to deprecate methods, instance variables, objects, and constants. It’s also available for gems or applications.
For a gem, use Deprecation.new to create a Deprecation object and store it in your module or class (in order for users to be able to configure it).
module MyLibrary def self.deprecator @deprecator ||= ActiveSupport::Deprecation.new("2.0", "MyLibrary") end end
For a Railtie or Engine, you may also want to add it to the application’s deprecators, so that the application’s configuration can be applied to it.
module MyLibrary class Railtie < Rails::Railtie initializer "my_library.deprecator" do |app| app.deprecators[:my_library] = MyLibrary.deprecator end end end
With the above initializer, configuration settings like the following will affect MyLibrary.deprecator:
# in config/environments/test.rb config.active_support.deprecation = :raise
Included modules
- ActiveSupport::Deprecation::Behavior
- ActiveSupport::Deprecation::Disallowed
- ActiveSupport::Deprecation::MethodWrapper
- ActiveSupport::Deprecation::Reporting
Constants
DEFAULT_BEHAVIORS = {\nraise: ->(message, callstack, deprecator) do\ne = DeprecationException.new(message)\ne.set_backtrace(callstack.map(&:to_s))\nraise e\nend,\n\nstderr: ->(message, callstack, deprecator) do\n$stderr.puts(message)\n$stderr.puts callstack.join("\\n ") if deprecator.debug\nend,\n\nlog: ->(message, callstack, deprecator) do\nlogger =\nif defined?(Rails.logger) && Rails.logger\nRails.logger\nelse\nrequire "active_support/logger"\nActiveSupport::Logger.new($stderr)\nend\nlogger.warn message\nlogger.debug callstack.join("\\n ") if deprecator.debug\nend,\n\nnotify: ->(message, callstack, deprecator) do\nActiveSupport::Notifications.instrument(\n"deprecation.#{deprecator.gem_name.underscore.tr("/", "_")}",\nmessage: message,\ncallstack: callstack,\ngem_name: deprecator.gem_name,\ndeprecation_horizon: deprecator.deprecation_horizon,\n)\nend,\n\nsilence: ->(message, callstack, deprecator) { },\n\nreport: ->(message, callstack, deprecator) do\nerror = DeprecationException.new(message)\nerror.set_backtrace(callstack.map(&:to_s))\nActiveSupport.error_reporter.report(error)\nend\n}
MUTEX = Mutex.new # :nodoc:
Attributes
| [RW] | deprecation_horizon |
Files
- activesupport/lib/active_support/deprecation.rb
- activesupport/lib/active_support/deprecation/behaviors.rb
- activesupport/lib/active_support/deprecation/constant_accessor.rb
- activesupport/lib/active_support/deprecation/deprecators.rb
- activesupport/lib/active_support/deprecation/disallowed.rb
- activesupport/lib/active_support/deprecation/method_wrappers.rb
- activesupport/lib/active_support/deprecation/proxy_wrappers.rb
- activesupport/lib/active_support/deprecation/reporting.rb