Sha256: 3c3363e22db4f0c019d978e217337b84dce4e94463ed2a466be580ab31cb144e

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

module Skylight
  module Util
    module InstrumenterMethod
      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
skylight-6.1.0.beta lib/skylight/util/instrumenter_method.rb
skylight-6.0.4 lib/skylight/util/instrumenter_method.rb
skylight-6.0.3 lib/skylight/util/instrumenter_method.rb
skylight-6.0.2 lib/skylight/util/instrumenter_method.rb
skylight-6.0.1 lib/skylight/util/instrumenter_method.rb
skylight-6.0.0 lib/skylight/util/instrumenter_method.rb
skylight-6.0.0.beta2 lib/skylight/util/instrumenter_method.rb
skylight-6.0.0.beta lib/skylight/util/instrumenter_method.rb