Class: Datadog::MethodWrapper

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#originalObject (readonly)

Returns the value of attribute original.



5
6
7
# File 'lib/ddtrace/augmentation/method_wrapper.rb', line 5

def original
  @original
end

#wrapperObject (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