module Datadog::Patcher::CommonMethods
Defines some common methods for patching, that can be used at the instance, class, or module level.
Public Instance Methods
do_once(key = nil, options = {}) { || ... }
click to toggle source
# File lib/ddtrace/patcher.rb, line 39 def do_once(key = nil, options = {}) DO_ONCE_USAGE_WARN_ONLY_ONCE.run do Datadog.logger.warn('Datadog::Patcher#do_once is deprecated. Use Datadog::Utils::OnlyOnce instead.') end # If already done, don't do again @done_once ||= Hash.new { |h, k| h[k] = {} } return @done_once[key][options[:for]] if @done_once.key?(key) && @done_once[key].key?(options[:for]) # Otherwise 'do' yield.tap do # Then add the key so we don't do again. @done_once[key][options[:for]] = true end
without_warnings() { || ... }
click to toggle source
# File lib/ddtrace/patcher.rb, line 27 def without_warnings # This is typically used when monkey patching functions such as # intialize, which Ruby advices you not to. Use cautiously. v = $VERBOSE $VERBOSE = nil begin yield ensure $VERBOSE = v end end