11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/unleash/strategy/flexible_rollout.rb', line 11
def is_enabled?(params = {}, context = nil)
return false unless params.is_a?(Hash)
return false unless context.instance_of?(Unleash::Context)
stickiness = params.fetch('stickiness', 'default')
stickiness_id = resolve_stickiness(stickiness, context)
begin
percentage = Integer(params.fetch('rollout', 0))
percentage = 0 if percentage > 100 || percentage.negative?
rescue ArgumentError
return false
end
group_id = params.fetch('groupId', '')
normalized_number = Util.get_normalized_number(stickiness_id, group_id)
return false if stickiness_id.nil?
(percentage.positive? && normalized_number <= percentage)
end
|