Class: Togglefy::BulkToggler

Inherits:
Object
  • Object
show all
Defined in:
lib/togglefy/services/bulk_toggler.rb

Overview

The BulkToggler class provides functionality to enable or disable features in bulk for assignables, such as users or accounts.

Constant Summary collapse

ALLOWED_ASSIGNABLE_FILTERS =

List of allowed filters for assignables.

%i[group role environment env tenant_id].freeze

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ BulkToggler

Initializes a new BulkToggler instance.

Parameters:

  • klass (Class)

    The assignable class (e.g., User, Account).



13
14
15
# File 'lib/togglefy/services/bulk_toggler.rb', line 13

def initialize(klass)
  @klass = klass
end

Instance Method Details

#disable(identifiers, **filters) ⇒ Object

Note:

All parameters but the first (identifiers) should be passed as keyword arguments.

Disables features for assignables based on filters.

Parameters:

  • identifiers (Array<String>, String)

    The feature identifiers to disable.

  • group (String)

    The group name to filter assignables by.

  • role (String)

    The role name to filter assignables by.

  • environment (String)

    The environment name to filter assignables by.

  • env (String)

    The environment name to filter assignables by.

  • tenant_id (String)

    The tenant_id to filter assignables by.

  • percentage (Integer)

    The percentage of assignables to include.



42
43
44
45
# File 'lib/togglefy/services/bulk_toggler.rb', line 42

def disable(identifiers, **filters)
  toggle(:disable, identifiers, filters)
  true
end

#enable(identifiers, **filters) ⇒ Object

Note:

All parameters but the first (identifiers) should be passed as keyword arguments.

Enables features for assignables based on filters.

Parameters:

  • identifiers (Array<String>, String)

    The feature identifiers to enable.

  • group (String)

    The group name to filter assignables by.

  • role (String)

    The role name to filter assignables by.

  • environment (String)

    The environment name to filter assignables by.

  • env (String)

    The environment name to filter assignables by.

  • tenant_id (String)

    The tenant_id to filter assignables by.

  • percentage (Integer)

    The percentage of assignables to include.



27
28
29
30
# File 'lib/togglefy/services/bulk_toggler.rb', line 27

def enable(identifiers, **filters)
  toggle(:enable, identifiers, filters)
  true
end