Browse files

Update to latest flipper API.

  • Loading branch information...
1 parent c394b9a commit 4affe21d3b46e1f506967d5423b741c6ad544745 @jnunemaker committed Feb 20, 2013
Showing with 27 additions and 12 deletions.
  1. +1 −1 flipper-redis.gemspec
  2. +26 −11 lib/flipper/adapters/redis.rb
View
2 flipper-redis.gemspec
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
- gem.add_dependency 'flipper', '~> 0.5.0'
+ gem.add_dependency 'flipper', '~> 0.6.0'
gem.add_dependency 'redis', '~> 3.0.0'
end
View
37 lib/flipper/adapters/redis.rb
@@ -21,6 +21,32 @@ def initialize(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.
@@ -85,17 +111,6 @@ def disable(feature, gate, thing)
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.

0 comments on commit 4affe21

Please sign in to comment.