Permalink
Browse files

Delegate redis keys to the rollout instance

  • Loading branch information...
1 parent 22c8901 commit eb8a6f3041533a5781436218bbed680c94ae4447 @jrallison committed Oct 16, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/rollout_ui/feature.rb
@@ -4,34 +4,36 @@ class Feature
attr_reader :name
+ delegate :percentage_key, :group_key, :user_key, :to => :rollout
+
def initialize(name)
@wrapper = Wrapper.new
@name = name
end
def percentage
- redis.get("feature:#{name}:percentage")
+ redis.get(percentage_key(name))
end
def groups
- redis.smembers("feature:#{name}:groups")
+ redis.smembers(group_key(name))
end
def users
- redis.smembers("feature:#{name}:users")
+ redis.smembers(user_key(name))
end
def percentage=(percentage)
rollout.activate_percentage(name, percentage)
end
def groups=(groups)
- redis.del("feature:#{name}:groups")
+ redis.del(group_key(name))
groups.each { |group| rollout.activate_group(name, group) }
end
def users=(users)
- redis.del("feature:#{name}:users")
+ redis.del(user_key(name))
users.each { |user| rollout.activate_user(name, User.new(user)) unless user.empty? }
end

0 comments on commit eb8a6f3

Please sign in to comment.