Togglefy::FeatureAssignableManager
The Togglefy::FeatureAssignableManager class provides methods to manage and check features for an individual assignable object.
See the examples on each method.
Methods
Section titled “Methods”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 # RequiredUsage Examples
Let’s pretend the assignable is a user object.
user = User.find(1)
Togglefy.for(user)Return
Togglefy::FeatureAssignableManagerenable
Section titled “enable”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 # RequiredUsage Examples
user = User.find(1)
Togglefy.for(user).enable(:teleportation)Return
Togglefy::FeatureAssignableManagerdisable
Section titled “disable”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 # RequiredUsage Examples
user = User.find(1)
Togglefy.for(user).disable(:teleportation)Return
Togglefy::FeatureAssignableManagerDescription
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 # RequiredUsage Examples
user = User.find(1)
Togglefy.for(user).has?(:teleportation)Return
true || falseDescription
Clear all features for an assignable.
Parameters
NoneUsage Examples
user = User.find(1)
Togglefy.for(user).clearReturn
Togglefy::FeatureAssignableManagerChainable Methods
Section titled “Chainable Methods”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)