class Ant::Configuration::FeatureFlag::ABTest
Public Class Methods
new(configs)
click to toggle source
# File lib/ant/configs/feature_flag/ab_test.rb, line 5 def initialize(configs) @configs = configs @threshold = normalize_thershold(configs['threshold']) end
Public Instance Methods
active?()
click to toggle source
# File lib/ant/configs/feature_flag/ab_test.rb, line 24 def active? rand <= @threshold end
normalize_thershold(value)
click to toggle source
# File lib/ant/configs/feature_flag/ab_test.rb, line 11 def normalize_thershold(value) case value when Integer raise 'Value out of range' unless (0..100).cover?(value) value.to_f / 100 when Float raise 'Value out of range' unless (0..1).cover?(value) value end end