Skip to content

Provided Rules Reference

Andrew De Ponte edited this page Jun 30, 2016 · 6 revisions

The following is a list of all of the provided rules, their explanations, and some examples of how they can be used.


This is the simplest of the provided rules. It simply takes a boolean during construction and returns that boolean value when run is called on it. Example:

rule = Togls.rule(:my_rule, :boolean, true) # => true


This rule is intended to allow feature toggles to be able to be controlled based on someone or something existing/not existing within a group. For example this could be used to enable a feature for a specified list of email addresses.

# Create a group rule
togls_devs = Togls.rule(:togls_devs, :group, ["", "", ""], :user_email_address)

# defining the feature toggles
Togls.release do
  feature(:new_contact_form, "use new contact form instead of old one", :user_email_address).on(togls_devs)

# evaluating the feature toggles
if Togls.feature(:new_contact_form).on?("")
  # Use new contact form
  # Use old contact form

In the above snippet the :new_contact_form feature toggle is on/off conditionally based on if "" is in the group ("", "", ""). In this particular case "" is not. Therefore, on? would come back with a value of false and we would end up in the # Use old contact form code branch.

Older Versions

Prior to v3.0.0 both these rules existed but their construction was as follows because the concepts of rule ids, rule types and target types didn't exist before v3.0.0.

rule =
togls_devs =["", "", ""])
You can’t perform that action at this time.