Sha256: 59f76fdcd324e819fb82b8fdfa938136eb166c15723a8b11af6cd98c3a827488

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'forwardable'
require 'thread'
require 'speed_gun/version'
require 'speed_gun/config'
require 'speed_gun/profile'
require 'speed_gun/middleware'

module SpeedGun
  class << self
    # @return [SpeedGun::Config] the config of speed gun
    def config
      @config ||= Config.new
    end

    # @return [SpeedGun::Profile, nil] the profile of a current thread
    def current_profile
      Thread.current[:speed_gun_current_profile]
    end

    # Set the profile of a current thread
    #
    # @param profile [SpeedGun::Profile] the profile
    # @return [SpeedGun::Profile] the profile of a current thread
    def current_profile=(profile)
      Thread.current[:speed_gun_current_profile] = profile
    end

    # Discard the profile of a current thread
    #
    # @return [nil]
    def discard_profile!
      self.current_profile = nil
    end

    # @see SpeedGun::Config#enabled?
    # @return [Boolean] true if enabled speed gun
    def enabled?
      config.enabled?
    end
  end
end

require 'speed_gun/railtie' if defined?(Rails)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
speed_gun-1.0.0.rc1 lib/speed_gun.rb