Module: RailsOnboarding::Deprecation
- Defined in:
- lib/rails_onboarding/deprecation.rb
Overview
Deprecation warnings utility module Provides consistent deprecation warnings across the gem
Class Method Summary collapse
-
.deprecate_config(option, replacement: nil, version: nil) ⇒ Object
Deprecate a configuration option.
-
.deprecate_format(format, new_format: nil, version: nil) ⇒ Object
Deprecate a data format.
-
.deprecate_method(old_method, new_method: nil, version: nil) ⇒ Object
Deprecate a method call.
-
.warn(message, version: nil) ⇒ Object
Issue a deprecation warning.
Class Method Details
.deprecate_config(option, replacement: nil, version: nil) ⇒ Object
Deprecate a configuration option
41 42 43 44 45 46 47 48 |
# File 'lib/rails_onboarding/deprecation.rb', line 41 def deprecate_config(option, replacement: nil, version: nil) = "Configuration option '#{option}' is deprecated" += " and will be removed in version #{version}" if version += ". Use '#{replacement}' instead" if replacement += "." warn(, version: version) end |
.deprecate_format(format, new_format: nil, version: nil) ⇒ Object
Deprecate a data format
54 55 56 57 58 59 60 61 |
# File 'lib/rails_onboarding/deprecation.rb', line 54 def deprecate_format(format, new_format: nil, version: nil) = "#{format} is deprecated" += " and support will be removed in version #{version}" if version += ". Please migrate to: #{new_format}" if new_format += "." warn(, version: version) end |
.deprecate_method(old_method, new_method: nil, version: nil) ⇒ Object
Deprecate a method call
28 29 30 31 32 33 34 35 |
# File 'lib/rails_onboarding/deprecation.rb', line 28 def deprecate_method(old_method, new_method: nil, version: nil) = "#{old_method} is deprecated" += " and will be removed in version #{version}" if version += ". Use #{new_method} instead" if new_method += "." warn(, version: version) end |
.warn(message, version: nil) ⇒ Object
Issue a deprecation warning
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_onboarding/deprecation.rb', line 11 def warn(, version: nil) = "[DEPRECATION] #{}" += " It will be removed in version #{version}." if version if defined?(ActiveSupport::Deprecation) # Use the default deprecator instance deprecator = ActiveSupport::Deprecation._instance || ActiveSupport::Deprecation.new deprecator.warn() else Rails.logger.warn() if defined?(Rails) end end |