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:
parent
0d4d17a0a9
commit
7a74b534cd
1 changed files with 13 additions and 2 deletions
|
@ -18,19 +18,30 @@ module Rhino
|
||||||
end
|
end
|
||||||
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
|
module To
|
||||||
|
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
# @deprecated use {#to_ruby} instead
|
# @deprecated use {#to_ruby} instead
|
||||||
def self.ruby(object)
|
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)
|
to_ruby(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @deprecated use {#to_javascript} instead
|
# @deprecated use {#to_javascript} instead
|
||||||
def self.javascript(object, scope = nil)
|
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)
|
to_javascript(object, scope)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue