Class: Togls::Rules::Group

Inherits:
Togls::Rule show all
Defined in:
lib/togls/rules/group.rb

Overview

Group Rule

The Group Rule is a provided Rule that expects to be given an Array as it’s initialization data and when evaluated determines the toggle state based on the given target being included in the Array that was passed in during initialization. This allows you to define various groups. For example:

alpha_testers = Togls::Rules::Group.new([‘[email protected]’, ‘[email protected]’]) Togls.features do

feature(:foo).on(alpha_testers)

end

if Togls.feature(:foo).on?(current_user.email)

...

end

Instance Attribute Summary

Attributes inherited from Togls::Rule

#data

Instance Method Summary collapse

Methods inherited from Togls::Rule

#id, #initialize

Constructor Details

This class inherits a constructor from Togls::Rule

Instance Method Details

#run(_key, target) ⇒ Object



20
21
22
# File 'lib/togls/rules/group.rb', line 20

def run(_key, target)
  @data.include?(target)
end