class Librato::Rails::Configuration
Adds yaml-based config and extra properties to the configuration class provided by librato-rack
github.com/librato/librato-rack/blob/master/lib/librato/rack/configuration.rb
Constants
- CONFIG_SETTABLE
- DEFAULT_SUITES
Attributes
config_by[RW]
config_file[RW]
Public Class Methods
new(options={})
click to toggle source
options:
-
:config_file - alternate config file location
Calls superclass method
# File lib/librato/rails/configuration.rb, line 21 def initialize(options={}) self.config_file = options[:config_file] || 'config/librato.yml' super() self.log_prefix = '[librato-rails] ' end
Public Instance Methods
load_configuration()
click to toggle source
detect and load configuration from config file or env vars
Calls superclass method
# File lib/librato/rails/configuration.rb, line 28 def load_configuration if self.config_file && File.exists?(self.config_file) configure_with_config_file else self.config_by = :environment super end self.tags = detect_tags # respect autorun and log_level env vars regardless of config method self.autorun = detect_autorun self.log_level = :info if log_level.blank? self.suites = '' if suites.nil? self.log_level = ENV['LIBRATO_LOG_LEVEL'] if ENV['LIBRATO_LOG_LEVEL'] end
Private Instance Methods
configure_with_config_file()
click to toggle source
# File lib/librato/rails/configuration.rb, line 47 def configure_with_config_file self.config_by = :config_file env_specific = YAML.load(ERB.new(File.read(config_file)).result)[::Rails.env] if env_specific settable = CONFIG_SETTABLE & env_specific.keys settable.each do |key| value = env_specific[key] value.symbolize_keys! if key == "tags" self.send("#{key}=", value) end end end
default_suites()
click to toggle source
Calls superclass method
# File lib/librato/rails/configuration.rb, line 60 def default_suites super + DEFAULT_SUITES end