Module: Datadog::Patcher::CommonMethods
- Included in:
- Datadog::Patcher
- Defined in:
- lib/ddtrace/patcher.rb
Overview
Defines some common methods for patching, that can be used at the instance, class, or module level.
Instance Method Summary collapse
Instance Method Details
#do_once(key = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ddtrace/patcher.rb', line 24 def do_once(key = nil) # If already done, don't do again @done_once ||= {} return @done_once[key] if @done_once.key?(key) # Otherwise 'do' yield.tap do # Then add the key so we don't do again. @done_once[key] = true end end |
#without_warnings ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# 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 |