Class: ScoutApm::Config::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/config.rb

Overview

Attempts to load a configuration file, and parse it as YAML. If the file is not found, inaccessbile, or unparsable, log a message to that effect, and move on.

Instance Method Summary collapse

Constructor Details

#initialize(context, file_path = nil, config = {}) ⇒ ConfigFile

Returns a new instance of ConfigFile.



384
385
386
387
388
389
# File 'lib/scout_apm/config.rb', line 384

def initialize(context, file_path=nil, config={})
  @context = context
  @config = config || {}
  @resolved_file_path = file_path || determine_file_path
  load_file(@resolved_file_path)
end

Instance Method Details

#any_keys_found?Boolean

Returns:

  • (Boolean)


404
405
406
407
408
# File 'lib/scout_apm/config.rb', line 404

def any_keys_found?
  KNOWN_CONFIG_OPTIONS.any? { |option|
    @settings.has_key?(option)
  }
end

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


400
401
402
# File 'lib/scout_apm/config.rb', line 400

def has_key?(key)
  @settings.has_key?(key)
end

#nameObject



410
411
412
# File 'lib/scout_apm/config.rb', line 410

def name
  "config-file"
end

#value(key) ⇒ Object



391
392
393
394
395
396
397
398
# File 'lib/scout_apm/config.rb', line 391

def value(key)
  if @file_loaded
    val = @settings[key]
    val.to_s.strip.length.zero? ? nil : val
  else
    nil
  end
end