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-4.1.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-4.0.0 lib/unleash/strategy/gradual_rollout_random.rb
unleash-3.2.5 lib/unleash/strategy/gradual_rollout_random.rb
unleash-3.2.4 lib/unleash/strategy/gradual_rollout_random.rb
unleash-3.2.3 lib/unleash/strategy/gradual_rollout_random.rb
unleash-3.2.2 lib/unleash/strategy/gradual_rollout_random.rb
unleash-3.2.1 lib/unleash/strategy/gradual_rollout_random.rb
unleash-3.2.0 lib/unleash/strategy/gradual_rollout_random.rb