Skip to content

Togglefy::FeatureAssignableManager

The Togglefy::FeatureAssignableManager class provides methods to manage and check features for an individual assignable object.

See the examples on each method.

Description


This method is used to create a new instance of the Togglefy::FeatureAssignableManager class for a specific assignable.

After creating the instance, you can use it to manage and check features for that assignable.

Parameters


assignable: assignable # Required

Usage Examples


Let’s pretend the assignable is a user object.

user = User.find(1)
Togglefy.for(user)

Return


Togglefy::FeatureAssignableManager

Description


Enable a feature for an assignable.

This method will enable the feature for the assignable, regardless of the feature’s status.

This is useful for testing or debugging purposes.

This method will not affect the feature’s status for other assignables.

Parameters


identifier: Symbol, String # Required

Usage Examples


user = User.find(1)
Togglefy.for(user).enable(:teleportation)

Return


Togglefy::FeatureAssignableManager

Description


Disable a feature for an assignable.

This method will disable the feature for the assignable, regardless of the feature’s status.

This is useful for testing or debugging purposes.

This method will not affect the feature’s status for other assignables.

Parameters


identifier: Symbol, String # Required

Usage Examples


user = User.find(1)
Togglefy.for(user).disable(:teleportation)

Return


Togglefy::FeatureAssignableManager

Description


Check if a feature is enabled for an assignable.

An assignable has a feature if there’s a Togglefy::FeatureAssignment record for the assignable and the feature.

It will only check for Togglefy::Feature that status is active.

Parameters


identifier: Symbol, String # Required

Usage Examples


user = User.find(1)
Togglefy.for(user).has?(:teleportation)

Return


true || false

Description


Clear all features for an assignable.

Parameters


None

Usage Examples


user = User.find(1)
Togglefy.for(user).clear

Return


Togglefy::FeatureAssignableManager

The following methods are chainable, meaning you can call them one after the other.

Usage Examples


# Instead of doing this:
Togglefy.for(assignable).disable(:alpha_access)
Togglefy.for(assignable).enable(:beta_access)
# You can go something like this:
Togglefy.for(assignable).disable(:alpha_access).enable(:beta_access)