Class: NewRelic::Plugin::Config
- Inherits:
-
Object
- Object
- NewRelic::Plugin::Config
- Defined in:
- lib/newrelic_plugin/config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.config ⇒ Object
Returns a memoized version of the configuration object.
- .config_file ⇒ Object
-
.config_file=(config_file) ⇒ Object
Set the name of the configuration file:.
- .config_yaml ⇒ Object
-
.config_yaml=(config_yaml) ⇒ Object
Set the content of the configuration as a YAML string.
Instance Method Summary collapse
-
#agents ⇒ Object
Return a hash of agent configuration information.
-
#initialize ⇒ Config
constructor
Creates an instance of a configuration object, loading the configuration from the YAML configuration file.
-
#newrelic ⇒ Object
Return a hash of NewRelic configuration information.
Constructor Details
#initialize ⇒ Config
Creates an instance of a configuration object, loading the configuration
from the YAML configuration file. Note: this method should not be used
directly, rather the global method config should be referenced instead.
26 27 28 29 |
# File 'lib/newrelic_plugin/config.rb', line 26 def initialize @options = YAML::load(Config.config_yaml) if Config.config_yaml @options = YAML::load(ERB.new(File.read(Config.config_file), 0, '<>').result) unless @options end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/newrelic_plugin/config.rb', line 22 def @options end |
Class Method Details
.config ⇒ Object
Returns a memoized version of the configuration object.
77 78 79 |
# File 'lib/newrelic_plugin/config.rb', line 77 def self.config @instance||=NewRelic::Plugin::Config.new end |
.config_file ⇒ Object
58 59 60 |
# File 'lib/newrelic_plugin/config.rb', line 58 def self.config_file @config_file||="config/newrelic_plugin.yml" end |
.config_file=(config_file) ⇒ Object
Set the name of the configuration file:
NewRelic::Plugin::Config.config_file="lib/config.yml"
53 54 55 56 57 |
# File 'lib/newrelic_plugin/config.rb', line 53 def self.config_file= config_file @config_file=config_file @config_yaml=nil @instance=nil end |
.config_yaml ⇒ Object
71 72 73 |
# File 'lib/newrelic_plugin/config.rb', line 71 def self.config_yaml @config_yaml end |
.config_yaml=(config_yaml) ⇒ Object
Set the content of the configuration as a YAML string
NewRelic::Plugin::Config.config_yaml="newrelic:\n test: 2\n test2: four\nagents:\n test: 4\n test2: six\n"
66 67 68 69 70 |
# File 'lib/newrelic_plugin/config.rb', line 66 def self.config_yaml= config_yaml @config_yaml=config_yaml @config_file=nil @instance=nil end |
Instance Method Details
#agents ⇒ Object
Return a hash of agent configuration information.
Usage: NewRelic::Plugin::Config.config.agents
44 45 46 |
# File 'lib/newrelic_plugin/config.rb', line 44 def agents @options["agents"] end |
#newrelic ⇒ Object
Return a hash of NewRelic configuration information.
Usage: NewRelic::Plugin::Config.config.newrelic
36 37 38 |
# File 'lib/newrelic_plugin/config.rb', line 36 def newrelic @options["newrelic"] end |