lib/flipper/adapters/redis.rb in flipper-redis-0.5.0 vs lib/flipper/adapters/redis.rb in flipper-redis-0.6.0

- old
+ new

@@ -19,10 +19,36 @@ def initialize(client) @client = client @name = :redis end + # Public: The set of known features. + def features + @client.smembers(FeaturesKey).to_set + end + + # Public: Adds a feature to the set of known features. + def add(feature) + @client.sadd FeaturesKey, feature.name + true + end + + # Public: Removes a feature from the set of known features. + def remove(feature) + @client.multi do + @client.srem FeaturesKey, feature.name + @client.del feature.key + end + true + end + + # Public: Clears the gate values for a feature. + def clear(feature) + @client.del feature.key + true + end + # Public: Gets the values for all gates for a given feature. # # Returns a Hash of Flipper::Gate#key => value. def get(feature) result = {} @@ -81,20 +107,9 @@ else unsupported_data_type gate.data_type end true - end - - # Public: Adds a feature to the set of known features. - def add(feature) - @client.sadd FeaturesKey, feature.name - true - end - - # Public: The set of known features. - def features - @client.smembers(FeaturesKey).to_set end # Private: Gets a hash of fields => values for the given feature. # # Returns a Hash of fields => values.