Class: Sail::Types::Throttle

Inherits:
Type
  • Object
show all
Defined in:
lib/sail/types/throttle.rb

Overview

Throttle

The Throttle type returns true X% of the time (randomly), where X is the value saved in the database.

Example:

If the setting value is 30, it will return true 30% of the time.

Instance Method Summary collapse

Methods inherited from Type

#from, #initialize

Constructor Details

This class inherits a constructor from Sail::Types::Type

Instance Method Details

#to_valueObject



16
17
18
# File 'lib/sail/types/throttle.rb', line 16

def to_value
  100 * rand <= @setting.value.to_f
end