Module: LcpRuby::ConditionServices::FeatureFlag
- Defined in:
- lib/lcp_ruby/condition_services/feature_flag.rb
Overview
Default ‘feature_flag` condition service. Returns false for every flag — i.e., flags are off by default. Hosts override by registering their own implementation:
LcpRuby::ConditionServiceRegistry.register(
"feature_flag", MyApp::FeatureFlagService
)
The host implementation accepts ‘params: { name: <flag>, … }` and returns a boolean. Tests for the override pattern live alongside the host’s flag service.
When the default returns false, it logs a one-shot dev warning per flag name (suppressed in ‘Rails.env.test?` so test suites don’t spam stderr when the host hasn’t wired feature flags yet). The latch is process-local and thread-safe via a Mutex — Puma running multiple threads on a single process won’t double-log.
Class Method Summary collapse
- .call(_record, context: {}, **args) ⇒ Object
-
.reset_warning_state! ⇒ Object
Test hook: clear the warned-flag set so per-flag warning specs can verify “warns once, not twice” without leaking state across examples.
Class Method Details
.call(_record, context: {}, **args) ⇒ Object
25 26 27 28 29 |
# File 'lib/lcp_ruby/condition_services/feature_flag.rb', line 25 def call(_record, context: {}, **args) flag = args[:name].to_s warn_unimplemented(flag) unless flag.empty? false end |
.reset_warning_state! ⇒ Object
Test hook: clear the warned-flag set so per-flag warning specs can verify “warns once, not twice” without leaking state across examples.
34 35 36 |
# File 'lib/lcp_ruby/condition_services/feature_flag.rb', line 34 def reset_warning_state! @warned_mutex.synchronize { @warned_flags = Set.new } end |