Module: DeprecationTracker::KernelWarnTracker

Included in:
DeprecationTracker
Defined in:
lib/deprecation_tracker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callbacksObject



17
18
19
# File 'lib/deprecation_tracker.rb', line 17

def self.callbacks
  @callbacks ||= []
end

Instance Method Details

#warn(*messages, uplevel: nil, category: nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/deprecation_tracker.rb', line 21

def warn(*messages, uplevel: nil, category: nil)
  KernelWarnTracker.callbacks.each do |callback|
    messages.each { |message| callback.(message) }
  end

  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5.0")
    super(*messages)
  elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0")
    super(*messages, uplevel: nil)
  else
    super
  end
end