Sha256: 508327c1f989de111d11a05b42b510cd97c22ff49be557e075bd20e982f7095e

Contents?: true

Size: 908 Bytes

Versions: 4

Compression:

Stored size: 908 Bytes

Contents

require 'thread'

module SpeedGun
  class << self
    attr_writer :config
  end

  def self.current
    Thread.current[:speed_gun_current]
  end

  def self.current=(profiler)
    Thread.current[:speed_gun_current] = profiler
  end

  def self.config
    @config ||= SpeedGun::Config.new
  end

  def self.active?
    current && current.active?
  end

  def self.activate!
    current && current.activate!
  end

  def self.deactivate!
    current && current.deactivate!
  end

  def self.enable?
    config.enable?
  end

  def self.store
    config.store
  end

  def self.profile(title, *args, &block)
    if title.kind_of?(String)
      current && current.profile(:manual, title, &block)
    else
      current && current.profile(title, *args, &block)
    end
  end
end

require 'speed_gun/version'
require 'speed_gun/config'
require 'speed_gun/middleware'
require 'speed_gun/railtie' if defined?(Rails)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
speed_gun-0.0.4 lib/speed_gun.rb
speed_gun-0.0.3 lib/speed_gun.rb
speed_gun-0.0.2 lib/speed_gun.rb
speed_gun-0.0.1 lib/speed_gun.rb