Condition Set API reference

This document describes the Condition Set API, which allows you to create your own custom switch validation logic.

class gargoyle.conditions.ConditionSet
can_execute(instance)

Given an instance, returns a boolean of whether this ConditionSet can return a valid condition check.

get_field_value(instance, field_name)

Given an instance, and the name of an attribute, returns the value of that attribute on the instance.

Default behavior will map the percent attribute to id.

get_group_label()

Returns a string representing a human readable version of this ConditionSet instance.

get_id()

Returns a string representing a unique identifier for this ConditionSet instance.

get_namespace()

Returns a string specifying a unique registration namespace for this ConditionSet instance.

has_active_condition(conditions, instances)

Given a list of instances, and the conditions active for this switch, returns a boolean reprsenting if any conditional is met, including a non-instance default.

is_active(instance, conditions)

Given an instance, and the conditions active for this switch, returns a boolean representing if the feature is active.