Module: ActiveSupport::Deprecation::ClassMethods
- Included in:
- Module
- Defined in:
- lib/active_support/deprecation.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#deprecate(*method_names) ⇒ Object
Declare that a method has been deprecated.
- #deprecated_method_warning(method_name, message = nil) ⇒ Object
- #deprecation_horizon ⇒ Object
Instance Method Details
#deprecate(*method_names) ⇒ Object
Declare that a method has been deprecated.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/active_support/deprecation.rb', line 88 def deprecate(*method_names) = method_names. method_names = method_names + .keys method_names.each do |method_name| alias_method_chain(method_name, :deprecation) do |target, punctuation| class_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{target}_with_deprecation#{punctuation}(*args, &block) # def generate_secret_with_deprecation(*args, &block) ::ActiveSupport::Deprecation.warn( # ::ActiveSupport::Deprecation.warn( self.class.deprecated_method_warning( # self.class.deprecated_method_warning( :#{method_name}, # :generate_secret, #{[method_name].inspect}), # "You should use ActiveSupport::SecureRandom.hex(64)"), caller # caller ) # ) send(:#{target}_without_deprecation#{punctuation}, *args, &block) # send(:generate_secret_without_deprecation, *args, &block) end # end EOS end end end |
#deprecated_method_warning(method_name, message = nil) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/active_support/deprecation.rb', line 108 def deprecated_method_warning(method_name, =nil) warning = "#{method_name} is deprecated and will be removed from Rails #{deprecation_horizon}" case when Symbol then "#{warning} (use #{} instead)" when String then "#{warning} (#{})" else warning end end |
#deprecation_horizon ⇒ Object
117 118 119 |
# File 'lib/active_support/deprecation.rb', line 117 def deprecation_horizon '2.3' end |