Features
Features are the heart of Flipper. They allow you to control code execution by enabling features in certain conditions.
Checking if a feature is enabled
if Flipper.enabled?(:my_feature)
# do the thing
else
# do the other thing
end
Managing features
Features can be added, removed, and listed using the Flipper DSL. Adding a feature registers it with the adapter without enabling it, which is useful for tracking known features in the UI or API.
Flipper.add
# Add a feature without enabling it
Flipper.add(:search)
Adding a feature makes it visible in the UI, API, and Flipper.features without changing its state. Features are also implicitly added when you enable them.
Flipper.remove
# Remove a feature and all its gate data
Flipper.remove(:search)
Removing a feature deletes it and all of its gate data (actors, groups, percentages, etc.) from the adapter. This is a destructive action—use Flipper.disable if you just want to turn a feature off.
Flipper.exist?
Flipper.exist?(:search) # false
Flipper.add(:search)
Flipper.exist?(:search) # true
Flipper.features
Flipper.add(:search)
Flipper.add(:stats)
Flipper.features.each do |feature|
puts feature.name
end
# => search
# => stats
Enabling and disabling features
Flipper allows you to enable and disable feature flags for different users at runtime. You have control over the scenarios and conditions that enable a feature for a given actor, group, percentage of actors, percentage of time, or even custom expressions that you define. This means you can turn features on and off for certain users—but not others—without deploying new code.
There are 6 different ways to enable a feature:
Get audit history, rollbacks, advanced permissions, analytics, and all of your projects in one place.
You can choose from several tiers to sponsor Flipper on GitHub and get some great benefits!