Sha256: a7f82c18daf1cedfc3f0ce6a2b36a6ea73b02ebe1a88d16a6d0eda16feda733c

Contents?: true

Size: 629 Bytes

Versions: 4

Compression:

Stored size: 629 Bytes

Contents

# frozen_string_literal: true

module InstrumentAllTheThings
  Context = Struct.new(:method_name, :instance, keyword_init: true) do
    def stats_name(klass_or_instance)
      @stats_name ||= [
        class_name(klass_or_instance),
        (instance ? 'instance' : 'class') + '_methods',
        method_name,
      ].join('.')
    end

    def trace_name(klass_or_instance)
      @trace_name ||= "#{class_name(klass_or_instance)}#{instance ? '.' : '#'}#{method_name}"
    end

    private

    def class_name(klass_or_instance)
      klass_or_instance.is_a?(Class) ? klass_or_instance.to_s : klass_or_instance
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
instrument_all_the_things-1.0.2 lib/instrument_all_the_things/context.rb
instrument_all_the_things-1.0.1 lib/instrument_all_the_things/context.rb
instrument_all_the_things-0.9.1.alpha lib/instrument_all_the_things/context.rb
instrument_all_the_things-0.9.0.alpha lib/instrument_all_the_things/context.rb