Module: StandardHealth
- Defined in:
- lib/standard_health.rb,
lib/standard_health/check.rb,
lib/standard_health/engine.rb,
lib/standard_health/version.rb,
lib/standard_health/env_spec.rb,
lib/standard_health/aggregator.rb,
lib/standard_health/configuration.rb,
lib/standard_health/checks/solid_cache.rb,
lib/standard_health/checks/solid_queue.rb,
lib/standard_health/checks/active_record.rb,
app/controllers/standard_health/health_controller.rb,
app/controllers/standard_health/application_controller.rb,
app/controllers/standard_health/diagnostics_controller.rb,
app/controllers/standard_health/diagnostics_application_controller.rb
Defined Under Namespace
Modules: Checks Classes: Aggregator, ApplicationController, Check, Configuration, DiagnosticsApplicationController, DiagnosticsController, Engine, EnvSpec, HealthController
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
- .config ⇒ Object
-
.configure {|config| ... } ⇒ Object
Yields the configuration to a block.
-
.diagnostics_parent_controller ⇒ Object
Resolves the parent class for ‘DiagnosticsController` only.
-
.parent_controller ⇒ Object
Resolves ‘config.parent_controller` to an actual class lazily — at the moment the engine’s ‘ApplicationController` is first referenced (request time), by which point the host app’s controllers are loaded.
-
.reset_config! ⇒ Object
Mostly useful in tests — wipes the singleton config so each example gets a clean slate.
- .reset_diagnostics_parent_controller! ⇒ Object
- .reset_parent_controller! ⇒ Object
Class Method Details
.config ⇒ Object
26 27 28 |
# File 'lib/standard_health.rb', line 26 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Yields the configuration to a block.
StandardHealth.configure do |c|
c.parent_controller = "ApplicationController"
c.register_check :db, StandardHealth::Checks::ActiveRecord, critical: true
end
21 22 23 24 |
# File 'lib/standard_health.rb', line 21 def configure yield config if block_given? config end |
.diagnostics_parent_controller ⇒ Object
Resolves the parent class for ‘DiagnosticsController` only. Falls back to `config.parent_controller` when no diagnostics-specific parent is configured, preserving v0.1.0 behavior. When set, lets host apps apply `before_action :auth, only: :env` to the diagnostics endpoint without that callback leaking onto `HealthController` (which would otherwise trip Rails 7.1’s ‘raise_on_missing_callback_actions`).
60 61 62 63 64 65 66 |
# File 'lib/standard_health.rb', line 60 def diagnostics_parent_controller expected = config.diagnostics_parent_controller || config.parent_controller if @diagnostics_parent_controller && @diagnostics_parent_controller.name != expected @diagnostics_parent_controller = nil end @diagnostics_parent_controller ||= expected.constantize end |
.parent_controller ⇒ Object
Resolves ‘config.parent_controller` to an actual class lazily — at the moment the engine’s ‘ApplicationController` is first referenced (request time), by which point the host app’s controllers are loaded. Caching avoids re-running ‘constantize` per request, and the name-mismatch reset lets tests swap config between examples.
41 42 43 44 45 46 47 |
# File 'lib/standard_health.rb', line 41 def parent_controller expected = config.parent_controller if @parent_controller && @parent_controller.name != expected @parent_controller = nil end @parent_controller ||= expected.constantize end |
.reset_config! ⇒ Object
Mostly useful in tests — wipes the singleton config so each example gets a clean slate.
32 33 34 |
# File 'lib/standard_health.rb', line 32 def reset_config! @config = Configuration.new end |
.reset_diagnostics_parent_controller! ⇒ Object
68 69 70 |
# File 'lib/standard_health.rb', line 68 def reset_diagnostics_parent_controller! @diagnostics_parent_controller = nil end |
.reset_parent_controller! ⇒ Object
49 50 51 |
# File 'lib/standard_health.rb', line 49 def reset_parent_controller! @parent_controller = nil end |