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 24 def do_once(key = nil, options = {}) # If already done, don't do again @done_once ||= Hash.new { |h, k| h[k] = {} } if @done_once.key?(key) && @done_once[key].key?(options[:for]) return @done_once[key][options[:for]] end # 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 12 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