Class: Prefab::FeatureFlagClient
- Inherits:
-
Object
- Object
- Prefab::FeatureFlagClient
- Includes:
- ConfigHelper
- Defined in:
- lib/prefab/feature_flag_client.rb
Constant Summary collapse
- MAX_32_FLOAT =
4294967294.0- DISTRIBUTION_SPACE =
1000
Instance Method Summary collapse
- #evaluate(feature_name, lookup_key, attributes, feature_obj) ⇒ Object
- #feature_is_on?(feature_name) ⇒ Boolean
- #feature_is_on_for?(feature_name, lookup_key, attributes: {}) ⇒ Boolean
- #get(feature_name, lookup_key, attributes) ⇒ Object
-
#initialize(base_client) ⇒ FeatureFlagClient
constructor
A new instance of FeatureFlagClient.
- #upsert(feature_name, feature_obj) ⇒ Object
Methods included from ConfigHelper
Constructor Details
#initialize(base_client) ⇒ FeatureFlagClient
Returns a new instance of FeatureFlagClient.
7 8 9 |
# File 'lib/prefab/feature_flag_client.rb', line 7 def initialize(base_client) @base_client = base_client end |
Instance Method Details
#evaluate(feature_name, lookup_key, attributes, feature_obj) ⇒ Object
30 31 32 |
# File 'lib/prefab/feature_flag_client.rb', line 30 def evaluate(feature_name, lookup_key, attributes, feature_obj) value_of(get_variant(feature_name, lookup_key, attributes, feature_obj)) end |
#feature_is_on?(feature_name) ⇒ Boolean
15 16 17 |
# File 'lib/prefab/feature_flag_client.rb', line 15 def feature_is_on?(feature_name) feature_is_on_for?(feature_name, nil) end |
#feature_is_on_for?(feature_name, lookup_key, attributes: {}) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/prefab/feature_flag_client.rb', line 19 def feature_is_on_for?(feature_name, lookup_key, attributes: {}) @base_client.stats.increment("prefab.featureflag.on", tags: ["feature:#{feature_name}"]) return is_on?(get(feature_name, lookup_key, attributes)) end |
#get(feature_name, lookup_key, attributes) ⇒ Object
25 26 27 28 |
# File 'lib/prefab/feature_flag_client.rb', line 25 def get(feature_name, lookup_key, attributes) feature_obj = @base_client.config_client.get(feature_name) evaluate(feature_name, lookup_key, attributes, feature_obj) end |
#upsert(feature_name, feature_obj) ⇒ Object
11 12 13 |
# File 'lib/prefab/feature_flag_client.rb', line 11 def upsert(feature_name, feature_obj) @base_client.config_client.upsert(feature_name, Prefab::ConfigValue.new(feature_flag: feature_obj)) end |