Sha256: 5b8b68cc6babc2f61d79b80f71bb521a34aac764e8ffab1a0b43c32cc7ef3830

Contents?: true

Size: 537 Bytes

Versions: 28

Compression:

Stored size: 537 Bytes

Contents

require 'unleash/strategy/util'

module Unleash
  module Strategy
    class GradualRolloutRandom < Base
      def name
        'gradualRolloutRandom'
      end

      # need: params['percentage']
      def is_enabled?(params = {}, _context = nil)
        return false unless params.is_a?(Hash) && params.has_key?('percentage')

        begin
          percentage = Integer(params['percentage'] || 0)
        rescue ArgumentError
          return false
        end

        (percentage >= Random.rand(1..100))
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
unleash-5.1.1 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.1.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.7 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.6 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.5 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.4 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.3 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.2 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.1 lib/unleash/strategy/gradual_rollout_random.rb
unleash-5.0.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.6.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.5.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.4.4 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.4.3 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.4.2 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.4.1 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.4.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.3.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.2.1 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.2.0 lib/unleash/strategy/gradual_rollout_random.rb