Module: Skylight::Util::InstrumenterMethod Private

Included in:
Skylight
Defined in:
lib/skylight/util/instrumenter_method.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#instrumenter_method(name, wrapped_block: false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/skylight/util/instrumenter_method.rb', line 4

def instrumenter_method(name, wrapped_block: false)
  if wrapped_block
    module_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{name}(...)                      # def mute(...)
        unless instrumenter                 #   unless instrumenter
          return yield if block_given?      #     return yield if block_given?
          return                            #     return
        end                                 #   end
                                            #
        instrumenter.#{name}(...)           #   instrumenter.mute(...)
      end                                   # end
    RUBY
  else
    module_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{name}(...)                      # def config(...)
        instrumenter&.#{name}(...)          #   instrumenter&.config(...)
      end                                   # end
    RUBY
  end
end