1
0
Fork 0
mirror of https://github.com/rubyjs/therubyrhino synced 2023-03-27 23:21:34 -04:00

only print each [DEPRECATION] once so we don't drive users crazy :)

This commit is contained in:
kares 2011-12-09 07:56:07 +01:00
parent 0d4d17a0a9
commit 7a74b534cd

View file

@ -18,19 +18,30 @@ module Rhino
end
end
@@warnings = {}
def self.warn(msg)
# only print out deprecation warnings once
if msg[0, 13] == '[DEPRECATION]'
return nil if @@warnings[msg]
@@warnings[msg] = true
end
super # Kernel.warn
end
module To
extend self
# @deprecated use {#to_ruby} instead
def self.ruby(object)
warn "[DEPRECATION] `Rhino::To.ruby` is deprecated, use `Rhino.to_ruby` instead."
Rhino.warn "[DEPRECATION] `Rhino::To.ruby` is deprecated, use `Rhino.to_ruby` instead."
to_ruby(object)
end
# @deprecated use {#to_javascript} instead
def self.javascript(object, scope = nil)
warn "[DEPRECATION] `Rhino::To.javascript` is deprecated, use `Rhino.to_javascript` instead."
Rhino.warn "[DEPRECATION] `Rhino::To.javascript` is deprecated, use `Rhino.to_javascript` instead."
to_javascript(object, scope)
end