lib/bastet/base.rb in bastet-0.1.1 vs lib/bastet/base.rb in bastet-0.1.2

- old
+ new

@@ -2,22 +2,32 @@ class Bastet::Base include Singleton def activate feature, group - Bastet.redis.sadd("feature_#{feature}", group.name) + act(:sadd, feature, group) end def deactivate feature, group - Bastet.redis.srem("feature_#{feature}", group.name) + act(:srem, feature, group) end def active? feature, entity - group_names = Bastet.redis.smembers("feature_#{feature}") + group_names = Bastet.redis.smembers(feature_key(feature)) groups = Bastet.groups.select { |group| group_names.include?(group.name) } groups.any? { |group| group.criteria.call(entity) } end def inactive? feature, entity !active? feature, entity end + + private + + def act method, feature, group + Bastet.redis.send(method, feature_key(feature), group.name) + end + + def feature_key feature + "feature_#{feature}" + end end