Class: Appsignal::Config
- Inherits:
-
Object
- Object
- Appsignal::Config
- Includes:
- CarefulLogger
- Defined in:
- lib/appsignal/config.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ :ignore_exceptions => [], :endpoint => 'https://push.appsignal.com/1', :slow_request_threshold => 200 }.freeze
Instance Attribute Summary collapse
-
#configurations ⇒ Object
readonly
Returns the value of attribute configurations.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Instance Method Summary collapse
-
#initialize(project_path, env, logger = Appsignal.logger) ⇒ Config
constructor
A new instance of Config.
- #load ⇒ Object
- #load_all ⇒ Object
Methods included from CarefulLogger
Constructor Details
#initialize(project_path, env, logger = Appsignal.logger) ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 23 |
# File 'lib/appsignal/config.rb', line 18 def initialize(project_path, env, logger=Appsignal.logger) @project_path = project_path || ENV['PWD'] @env = env.to_sym @logger = logger @configurations = {} end |
Instance Attribute Details
#configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
16 17 18 |
# File 'lib/appsignal/config.rb', line 16 def configurations @configurations end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
16 17 18 |
# File 'lib/appsignal/config.rb', line 16 def env @env end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
16 17 18 |
# File 'lib/appsignal/config.rb', line 16 def project_path @project_path end |
Instance Method Details
#load ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/appsignal/config.rb', line 25 def load return unless load_configurations return unless used_unique_api_keys return unless current_environment_present if Appsignal.respond_to?(:logger) && @logger == Appsignal.logger @logger.level = Logger::DEBUG if configurations[env][:debug] end DEFAULT_CONFIG.merge(configurations[env]) end |
#load_all ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/appsignal/config.rb', line 36 def load_all return unless load_configurations return unless used_unique_api_keys {}.tap do |result| configurations.each do |env, config| result[env] = DEFAULT_CONFIG.merge(config) end end end |