Class: Togls::Rules::Boolean

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

Overview

Boolean Rule

The Boolean Rule is a provided Rule that expects to be given a boolean as it’s initialization data and when evaluated determines the toggle state based on the initialization value. Example:

always_on = Togls::Rules::Boolean.new(:on, :boolean, true) Togls.features do

feature(:foo).on(always_on)

end

if Togls.feature(:foo).on?

...

end

Instance Attribute Summary

Attributes inherited from Togls::Rule

#data, #id, #type_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Togls::Rule

#initialize, #missing_target_type?, #target_type

Constructor Details

This class inherits a constructor from Togls::Rule

Class Method Details

.descriptionObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/togls/rules/boolean.rb', line 22

def self.description
  %Q{
The Boolean rule type is the base line rule for Togls. It allows you to
flag a feature on/off by specifing a boolean value as the initialization
data. For example:

Togls::Rules::Boolean.new(:on, :boolean, true) # rule that always evaluates to on

Togls::Rules::Boolean.new(:off, :boolean, false) # rule that always evaluates to off
  }
end

.target_typeObject



34
35
36
# File 'lib/togls/rules/boolean.rb', line 34

def self.target_type
  Togls::TargetTypes::NONE
end

.titleObject



18
19
20
# File 'lib/togls/rules/boolean.rb', line 18

def self.title
  "Boolean"
end

Instance Method Details

#run(_key, _target = nil) ⇒ Object



38
39
40
# File 'lib/togls/rules/boolean.rb', line 38

def run(_key, _target = nil)
  @data
end