lib/flipper/adapters/redis.rb in flipper-redis-0.11.0.beta9 vs lib/flipper/adapters/redis.rb in flipper-redis-0.11.0.rc1
- old
+ new
@@ -21,11 +21,11 @@
@name = :redis
end
# Public: The set of known features.
def features
- @client.smembers(FeaturesKey).to_set
+ read_feature_keys
end
# Public: Adds a feature to the set of known features.
def add(feature)
@client.sadd FeaturesKey, feature.key
@@ -54,18 +54,18 @@
doc = doc_for(feature)
result_for_feature(feature, doc)
end
def get_multi(features)
- docs = docs_for(features)
- result = {}
- features.zip(docs) do |feature, doc|
- result[feature.key] = result_for_feature(feature, doc)
- end
- result
+ read_many_features(features)
end
+ def get_all
+ features = read_feature_keys.map { |key| Flipper::Feature.new(key, self) }
+ read_many_features(features)
+ end
+
# Public: Enables a gate for a given thing.
#
# feature - The Flipper::Feature for the gate.
# gate - The Flipper::Gate to disable.
# thing - The Flipper::Type being enabled for the gate.
@@ -102,9 +102,24 @@
else
unsupported_data_type gate.data_type
end
true
+ end
+
+ private
+
+ def read_many_features(features)
+ docs = docs_for(features)
+ result = {}
+ features.zip(docs) do |feature, doc|
+ result[feature.key] = result_for_feature(feature, doc)
+ end
+ result
+ end
+
+ def read_feature_keys
+ @client.smembers(FeaturesKey).to_set
end
# Private: Gets a hash of fields => values for the given feature.
#
# Returns a Hash of fields => values.