Sha256: bd7e2268131cab6184bb118602844fdcacef4b316e55a293501d4a157ee50627

Contents?: true

Size: 424 Bytes

Versions: 14

Compression:

Stored size: 424 Bytes

Contents

# frozen_string_literal: true

module Sail
  module Types
    # 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.
    class Throttle < Type
      def to_value
        100 * rand <= @setting.value.to_f
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sail-3.6.1 lib/sail/types/throttle.rb
sail-3.6.0 lib/sail/types/throttle.rb
sail-3.5.1 lib/sail/types/throttle.rb
sail-3.5.0 lib/sail/types/throttle.rb
sail-3.4.0 lib/sail/types/throttle.rb
sail-3.3.0 lib/sail/types/throttle.rb
sail-3.2.4 lib/sail/types/throttle.rb
sail-3.2.3 lib/sail/types/throttle.rb
sail-3.2.2 lib/sail/types/throttle.rb
sail-3.2.1 lib/sail/types/throttle.rb
sail-3.2.0 lib/sail/types/throttle.rb
sail-3.1.0 lib/sail/types/throttle.rb
sail-3.0.1 lib/sail/types/throttle.rb
sail-3.0.0 lib/sail/types/throttle.rb