Sha256: 24f944d087a659a56b36db7edd3a6d2bc1618f3ba236ccb1c768698e8dbacbba

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

module Skylight
  module Util
    module InstrumenterMethod
      def instrumenter_method(name, block: false)
        if block
          module_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{name}(*args)
              unless instrumenter
                return yield if block_given?
                return
              end

              instrumenter.#{name}(*args) { yield }
            end
          RUBY
        else
          module_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{name}(*args)
              instrumenter&.#{name}(*args)
            end
          RUBY
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
skylight-5.0.0.beta2 lib/skylight/util/instrumenter_method.rb
skylight-5.0.0.beta lib/skylight/util/instrumenter_method.rb