Skip to content

Commit

Permalink
add task to clear a feature with the specified strategy
Browse files Browse the repository at this point in the history
This task replicates the "Clear" feature from the dashboard.
With it, a feature can be cleared (unset) using the specified
strategy.
  • Loading branch information
kevinnio committed May 11, 2019
1 parent fd67a48 commit 38c99a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/tasks/flipflop.rake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ namespace :flipflop do
puts "Feature :#{args[:feature]} disabled!"
end

desc 'Clears a feature with the specified strategy.'
task :clear, %i[feature strategy] => :environment do |_task, args|
m.clear_feature! args[:feature], args[:strategy]
puts "Feature :#{args[:feature]} cleared!"
end

desc 'Shows features table'
task features: :environment do
# Build features table...
Expand Down
7 changes: 7 additions & 0 deletions lib/tasks/support/methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def switch_feature!(feature_name, strategy_name, value)
raise "The :#{strategy_name} strategy doesn't support switching."
end
end

def clear_feature!(feature_name, strategy_name)
feature = find_feature_by_name(feature_name)
strategy = find_strategy_by_name(strategy_name)

strategy.clear!(feature.key)
end
end
end
end

0 comments on commit 38c99a5

Please sign in to comment.