SimpleFeatureFlags (Simple Feature Flags v0.1.4)
View SourceThis module includes functions for checking whether a feature is enabled (enabled?/1
), and for introspecting configuration (current_configuration_to_string/0
).
Summary
Functions
Return the current configuration as a human-friendly string.
This function answers the question "Is feature X enabled in the current deployment environment?"
Functions
Return the current configuration as a human-friendly string.
If the configuration appears invalid, the function raises an exception.
Examples
iex> SimpleFeatureFlags.current_configuration_to_string()
"Current Deployment Environment: :test.\nFeatures:\n - test_feature_1 is ON. Enabled in [:all].\n - test_feature_2 is ON. Enabled in :all.\n - test_feature_3 is ON. Enabled in [:test].\n - test_feature_4 is ON. Enabled in [:staging, :test, :production].\n - test_feature_5 is OFF. Enabled in [:staging, :production].\n - test_feature_6 is OFF. Enabled in [].\n"
This function answers the question "Is feature X enabled in the current deployment environment?"
If feature X is not mentioned in your configuration, the function raises an exception.
Examples
iex> SimpleFeatureFlags.enabled?(:test_feature_1)
true
iex> SimpleFeatureFlags.enabled?(:no_such_feature)
** (RuntimeError) Unknown feature 'no_such_feature'. Known features: test_feature_1, test_feature_2, test_feature_3, test_feature_4, test_feature_5, test_feature_6.