Skip to content

Togglefy::FeatureManager

The Togglefy::FeatureManager class provides methods to manage features, including creating, updating, deleting and toggling their status.

For all methods here, excpet the create, you need to initialize the feature by passing the identifier before you can actually call the method.

See the examples on each method.

Description


Create a new feature.

Alias


create_feature

Parameters


name: String # Required
identifier: Symbol, String, nil
description: String, nil
group: String, Symbol, nil
environment: String, Symbol, nil
tenant_id: String, nil
status: String, Symbol, Integer, nil # Default to 0 or inactive

Usage Examples


Togglefy.create(
name: "Teleportation",
description: "Allows the assignable to teleport to anywhere",
group: :jumper,
status: :active
)
Togglefy.create_feature(
name: "Magic",
identifier: :wizardry,
description: "You're a Wizard, Harry"
)
Togglefy.create(
name: "Super Powers",
description: "With great power comes great responsibility",
tenant_id: "123abc",
group: :admin,
environment: :production
)

Return


Togglefy::Feature

Description


Update an existing feature.

Alias


update_feature

Parameters


First parameter, which is positional:

identifier: Symbol, String

Other parameters, which are keyword arguments:

name: String # Required
identifier: Symbol, String, nil
description: String, nil
group: String, Symbol, nil
environment: String, Symbol, nil
tenant_id: String, nil
status: String, Symbol, Integer, nil # Default to 0 or inactive

Usage Examples


Togglefy.update(:teleportation, name: "Teleportation 2.0", identifier: :teleportation_2)
Togglefy.update_feature(:teleportation, status: :inactive)
Togglefy.update(:teleportation, status: :active, group: :powers)

Return


Togglefy::Feature

Description


Delete a feature.

Alias


destroy_feature

Parameters


identifier: Symbol, String

Usage Examples


Togglefy.destroy(:teleportation)
Togglefy.destroy_feature(:teleportation)

Return


Togglefy::Feature

Description


Toggle the status of a feature.

Alias


toggle_feature

Parameters


identifier: Symbol, String

Usage Examples


Togglefy.toggle(:teleportation)
Togglefy.toggle_feature(:teleportation)

Return


Togglefy::Feature

Description


Set the status of a feature to active.

Alias


activate_feature

Parameters


identifier: Symbol, String

Usage Examples


Togglefy.active!(:teleportation)
Togglefy.activate_feature(:teleportation)

Return


Togglefy::Feature

Description


Set the status of a feature to inactive.

Alias


inactivate_feature

Parameters


identifier: Symbol, String

Usage Examples


Togglefy.inactive!(:teleportation)
Togglefy.inactivate_feature(:teleportation)

Return


Togglefy::Feature