Module | Sequel::Deprecation |
In: |
lib/sequel/deprecated.rb
|
This module makes it easy to print deprecation warnings with optional backtraces to a given stream. There are a couple of methods you can use to change where the deprecation methods are printed and whether they should include backtraces:
Sequel::Deprecation.output = $stderr # print deprecation messages to standard error (default) Sequel::Deprecation.output = File.open('deprecated_calls.txt', 'wb') # use a file instead Sequel::Deprecation.backtraces = false # don't include backtraces Sequel::Deprecation.backtraces = true # include full backtraces Sequel::Deprecation.backtraces = 10 # include 10 backtrace lines (default) Sequel::Deprecation.backtraces = 1 # include 1 backtrace line
Print the message to the output stream
# File lib/sequel/deprecated.rb, line 25 25: def self.deprecate(method, instead=nil) 26: message = instead ? "#{method} is deprecated and will be removed in Sequel 3.0. #{instead}." : method 27: return unless output 28: output.puts(message) 29: case backtraces 30: when Integer 31: b = backtraces 32: caller.each do |c| 33: b -= 1 34: output.puts(c) 35: break if b == 0 36: end 37: when true 38: caller.each{|c| output.puts(c)} 39: end 40: end