blob: a72b12bcfe97e43bff412585f682a8b5a87f2c4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
module ActiveSupport
module Deprecation
@@warning_method = :print
mattr_accessor :warning_method
class << self
def print_warning(lines)
lines.each {|l| $stderr.write("#{l}\n")}
end
def log_warning(lines)
if Object.const_defined?("RAILS_DEFAULT_LOGGER")
lines.each {|l| RAILS_DEFAULT_LOGGER.warn l}
else
print_warning(lines)
end
end
def issue_warning(line)
lines =
["@@@@@@@@@@ Deprecation Warning @@@@@@@@@@", line,
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"]
self.send("#{@@warning_method}_warning", lines)
end
def instance_method_warning(clazz, method)
issue_warning("Your application calls #{clazz}##{method}, which is now deprecated. Please see the API documents at http://api.rubyonrails.org/ for more information.")
end
end
module ClassMethods
def deprecate(method_name)
alias_method "#{method_name}_before_deprecation", method_name
class_eval(<<-EOS, __FILE__, __LINE__)
def #{method_name}(*args)
::ActiveSupport::Deprecation.instance_method_warning(self.class, :#{method_name})
#{method_name}_before_deprecation *args
end
EOS
end
end
end
end
Object.extend(ActiveSupport::Deprecation::ClassMethods)
|