20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/active_support/deprecation/instance_delegator.rb', line 20
def method_added(method_name)
use_instead =
case method_name
when :silence, :behavior=, :disallowed_behavior=, :disallowed_warnings=, :silenced=, :debug=
target = "(defined?(Rails.application.deprecators) ? Rails.application.deprecators : ActiveSupport::Deprecation._instance)"
"Rails.application.deprecators.#{method_name}"
when :warn, :deprecate_methods, :gem_name, :gem_name=, :deprecation_horizon, :deprecation_horizon=
"your own Deprecation object"
else
"Rails.application.deprecators[framework].#{method_name} where framework is for example :active_record"
end
args = /[^\]]=\z/.match?(method_name) ? "arg" : "..."
target ||= "ActiveSupport::Deprecation._instance"
singleton_class.module_eval " def \#{method_name}(\#{args})\n \#{target}.\#{method_name}(\#{args})\n ensure\n ActiveSupport.deprecator.warn(\"Calling \#{method_name} on ActiveSupport::Deprecation is deprecated and will be removed from Rails (use \#{use_instead} instead)\")\n end\n RUBY\nend\n", __FILE__, __LINE__ + 1
|