123456789_123456789_123456789_123456789_123456789_

Module: Timezone::Deprecate

Relationships & Source Files
Defined in: lib/timezone/deprecate.rb

Overview

This class provides a way to set a custom hook for deprecations.

Class Attribute Summary

Class Method Summary

Class Attribute Details

.callback (rw, private)

[ GitHub ]

  
# File 'lib/timezone/deprecate.rb', line 24

def callback
  @callback || ->(_, _, message) { warn(message) }
end

.callback=(value) (rw)

Set the custom deprecation callback. By default this issues a deprecation warning.

Examples:

Send a message to StatsD

Timezone::Deprecate.callback = lambda do |klass, method, _|
  StatsD.increment(sanitize(klass, method))
end

Send a message to a custom logger

Timezone::Deprecate.callback = lambda do |klass, method, msg|
  MyLogger.log("[#{klass} : #{method}] #{msg}")
end

Parameters:

  • callback (#call)

    the custom callback

[ GitHub ]

  
# File 'lib/timezone/deprecate.rb', line 21

attr_writer :callback

Class Method Details

.call(klass, method, message) (private)

[ GitHub ]

  
# File 'lib/timezone/deprecate.rb', line 29

def call(klass, method, message)
  callback && callback.call(klass, method, message)
end