module NewRelic::Control::ClassMethods
class-level methods for lazy creation of NewRelic::Control
and NewRelic::LocalEnvironment
instances.
Public Instance Methods
Source
# File lib/new_relic/control/class_methods.rb, line 12 def instance(create = true) @instance ||= create && new_instance end
Access the Control
singleton, lazy initialized. Default will instantiate a new instance or pass false to defer
Source
# File lib/new_relic/control/class_methods.rb, line 45 def load_framework_class(framework) begin require "new_relic/control/frameworks/#{framework}" rescue LoadError # maybe it is already loaded by some external system # i.e. rpm_contrib or user extensions? end NewRelic::Control::Frameworks.const_get(NewRelic::LanguageSupport.camelize(framework.to_s)) end
Loads the specified framework class from the NewRelic::Control::Frameworks
module
Source
# File lib/new_relic/control/class_methods.rb, line 37 def load_test_framework config = File.expand_path(File.join('..', '..', '..', '..', 'test', 'config', 'newrelic.yml'), __FILE__) require 'config/test_control' NewRelic::Control::Frameworks::Test.new(local_env, config) end
nb this does not ‘load test’ the framework, it loads the ‘test framework’
Source
# File lib/new_relic/control/class_methods.rb, line 23 def local_env @local_env ||= NewRelic::LocalEnvironment.new end
Access the LocalEnvironment
singleton, lazy initialized
Source
# File lib/new_relic/control/class_methods.rb, line 28 def new_instance if Agent.config[:framework] == :test load_test_framework else load_framework_class(Agent.config[:framework]).new(local_env) end end
Create the concrete class for environment specific behavior
Source
# File lib/new_relic/control/class_methods.rb, line 56 def newrelic_root File.expand_path(File.join('..', '..', '..', '..'), __FILE__) end
The root directory for the plugin or gem