Module: NewRelic::Control::ClassMethods

Included in:
NewRelic::Control
Defined in:
lib/new_relic/control.rb

Instance Method Summary collapse

Instance Method Details

#instanceObject

Access the Control singleton, lazy initialized



42
43
44
# File 'lib/new_relic/control.rb', line 42

def instance
  @instance ||= new_instance
end

#new_instanceObject

Create the concrete class for environment specific behavior:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_relic/control.rb', line 47

def new_instance
  @local_env = NewRelic::LocalEnvironment.new
  if @local_env.framework == :test
    # You can set this env var if you want to run the tests
    # without Rails.
    config = File.expand_path("../../../test/config/newrelic.yml", __FILE__)
    if ENV['SKIP_RAILS']
      require "new_relic/control/frameworks/ruby.rb"
      NewRelic::Control::Frameworks::Ruby.new @local_env, config
    else
      require "config/test_control"
      NewRelic::Control::Frameworks::Test.new @local_env, config
    end
  else
    begin
      require "new_relic/control/frameworks/#{@local_env.framework}.rb"
    rescue LoadError
    end
    NewRelic::Control::Frameworks.const_get(@local_env.framework.to_s.capitalize).new @local_env
  end
end

#newrelic_rootObject

The root directory for the plugin or gem



70
71
72
# File 'lib/new_relic/control.rb', line 70

def newrelic_root
  File.expand_path("../../..", __FILE__)
end