class Togls::Rules::Boolean

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

Public Class Methods

description() click to toggle source
# 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_type() click to toggle source
# File lib/togls/rules/boolean.rb, line 34
def self.target_type
  Togls::TargetTypes::NONE
end
title() click to toggle source
# File lib/togls/rules/boolean.rb, line 18
def self.title
  "Boolean"
end

Public Instance Methods

run(_key, _target = nil) click to toggle source
# File lib/togls/rules/boolean.rb, line 38
def run(_key, _target = nil)
  @data
end