Class: Datadog::MethodWrapper
- Inherits:
-
Object
- Object
- Datadog::MethodWrapper
- Defined in:
- lib/ddtrace/augmentation/method_wrapper.rb
Overview
Represents an wrapped method, with a reference to the original block and the block that wraps around it.
Constant Summary collapse
- DEFAULT_WRAPPER =
proc { |original, *args, &block| original.call(*args, &block) }
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object
-
#initialize(original, &block) ⇒ MethodWrapper
constructor
A new instance of MethodWrapper.
Constructor Details
#initialize(original, &block) ⇒ MethodWrapper
Returns a new instance of MethodWrapper.
11 12 13 14 |
# File 'lib/ddtrace/augmentation/method_wrapper.rb', line 11 def initialize(original, &block) @original = original @wrapper = block_given? ? block : DEFAULT_WRAPPER end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
5 6 7 |
# File 'lib/ddtrace/augmentation/method_wrapper.rb', line 5 def original @original end |
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
5 6 7 |
# File 'lib/ddtrace/augmentation/method_wrapper.rb', line 5 def wrapper @wrapper end |
Instance Method Details
#call(*args, &block) ⇒ Object
16 17 18 |
# File 'lib/ddtrace/augmentation/method_wrapper.rb', line 16 def call(*args, &block) wrapper.call(original, *args, &block) end |