Class: StandardHealth::Configuration
- Inherits:
-
Object
- Object
- StandardHealth::Configuration
- Defined in:
- lib/standard_health/configuration.rb
Overview
Holds engine-wide configuration.
Host apps configure the engine via:
StandardHealth.configure do |c|
c.parent_controller = "ApplicationController"
c.register_check :custom, MyCheck, critical: true
c.env_spec = StandardHealth::EnvSpec.define { ... }
end
Defined Under Namespace
Classes: Registration
Instance Attribute Summary collapse
-
#env_spec ⇒ Object
An optional ‘StandardHealth::EnvSpec` instance describing required and recommended environment variables for the host app.
-
#parent_controller ⇒ Object
Class name of the controller that StandardHealth’s controllers should inherit from.
Instance Method Summary collapse
-
#checks ⇒ Array<Registration>
Frozen view of registered checks.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#register_check(name, klass, critical: false) ⇒ Object
Register a health check class.
-
#reset_checks! ⇒ Object
Remove all registered checks.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
33 34 35 36 37 |
# File 'lib/standard_health/configuration.rb', line 33 def initialize @parent_controller = "ActionController::API" @env_spec = nil @checks = [] end |
Instance Attribute Details
#env_spec ⇒ Object
An optional ‘StandardHealth::EnvSpec` instance describing required and recommended environment variables for the host app. Audited via the /diagnostics/env endpoint.
31 32 33 |
# File 'lib/standard_health/configuration.rb', line 31 def env_spec @env_spec end |
#parent_controller ⇒ Object
Class name of the controller that StandardHealth’s controllers should inherit from. Resolved lazily via ‘constantize` at request time so the host app’s controller (which may pull in auth concerns) is fully loaded before we touch it. Defaults to ‘ActionController::API` so the engine works in API-only host apps without configuration.
26 27 28 |
# File 'lib/standard_health/configuration.rb', line 26 def parent_controller @parent_controller end |
Instance Method Details
#checks ⇒ Array<Registration>
Returns frozen view of registered checks.
49 50 51 |
# File 'lib/standard_health/configuration.rb', line 49 def checks @checks.dup end |
#register_check(name, klass, critical: false) ⇒ Object
Register a health check class.
44 45 46 |
# File 'lib/standard_health/configuration.rb', line 44 def register_check(name, klass, critical: false) @checks << Registration.new(name: name.to_sym, klass: klass, critical: critical) end |
#reset_checks! ⇒ Object
Remove all registered checks. Mainly useful in tests where the host app and the engine share a process.
55 56 57 |
# File 'lib/standard_health/configuration.rb', line 55 def reset_checks! @checks = [] end |