lib/rollout.rb in rollout-2.4.1 vs lib/rollout.rb in rollout-2.4.2

- old
+ new

@@ -2,10 +2,12 @@ require "zlib" require "set" require "json" class Rollout + RAND_BASE = (2**32 - 1) / 100.0 + class Feature attr_accessor :groups, :users, :percentage, :data attr_reader :name, :options def initialize(name, string = nil, opts = {}) @@ -86,11 +88,11 @@ def id_user_by @options[:id_user_by] || :id end def user_in_percentage?(user) - Zlib.crc32(user_id_for_percentage(user)) % 100_000 < @percentage * 1_000 + Zlib.crc32(user_id_for_percentage(user)) < RAND_BASE * @percentage end def user_id_for_percentage(user) if @options[:randomize_percentage] user_id(user).to_s + @name.to_s @@ -279,9 +281,13 @@ with_feature(feature) { |f| f.clear } @storage.del(key(feature)) end @storage.del(features_key) + end + + def exists?(feature) + @storage.exists(key(feature)) end private def key(name)