Module: Lich::Common::FeatureFlags
- Defined in:
- documented/common/feature_flags.rb
Overview
Provides persistent access to core feature flags.
Provides persistent access to core feature flags.
Constant Summary collapse
- SETTINGS_PREFIX =
'feature_flag:'- VALID_NAME_PATTERN =
/\A[a-z0-9_]+\z/- DEFAULTS =
Defines default values for known feature flags.
Add new flags here as infrastructure is adopted by production code. The persisted value in
lich_settingsalways overrides the default. {}.freeze
Class Method Summary collapse
-
.enabled?(name) ⇒ Boolean
Checks if a feature flag is enabled.
-
.set(name, value) ⇒ Boolean
Sets the value of a feature flag.
Class Method Details
.enabled?(name) ⇒ Boolean
Checks if a feature flag is enabled.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'documented/common/feature_flags.rb', line 26 def self.enabled?(name) flag_name = validate_flag_name!(normalize_name(name)) begin stored = read_flag(flag_name) return default_for(flag_name) if stored.nil? truthy?(stored) rescue StandardError => e log_failure('read', flag_name, e) default_for(flag_name) end end |
.set(name, value) ⇒ Boolean
Sets the value of a feature flag.
47 48 49 50 51 52 53 54 55 |
# File 'documented/common/feature_flags.rb', line 47 def self.set(name, value) flag_name = validate_flag_name!(normalize_name(name)) begin write_flag(flag_name, value) rescue StandardError => e log_failure('write', flag_name, e) false end end |