Class: FeatureHub::Sdk::EnvironmentInterceptor
- Inherits:
-
ValueInterceptor
- Object
- ValueInterceptor
- FeatureHub::Sdk::EnvironmentInterceptor
- Defined in:
- lib/feature_hub/sdk/interceptors.rb
Overview
An example of a value interceptor that uses environment variables
Instance Method Summary collapse
-
#initialize ⇒ EnvironmentInterceptor
constructor
A new instance of EnvironmentInterceptor.
- #intercepted_value(feature_key, _repository, _feature_state) ⇒ Object
Methods inherited from ValueInterceptor
Constructor Details
#initialize ⇒ EnvironmentInterceptor
Returns a new instance of EnvironmentInterceptor.
37 38 39 40 |
# File 'lib/feature_hub/sdk/interceptors.rb', line 37 def initialize super() @enabled = ENV.fetch("FEATUREHUB_OVERRIDE_FEATURES", "false") == "true" end |
Instance Method Details
#intercepted_value(feature_key, _repository, _feature_state) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/feature_hub/sdk/interceptors.rb', line 42 def intercepted_value(feature_key, _repository, _feature_state) if @enabled found = ENV.fetch("FEATUREHUB_#{sanitize_feature_name(feature_key.to_s)}", nil) return [true, found] unless found.nil? end [false, nil] end |