Module: Flipflop::Rake::SupportMethods

Defined in:
lib/tasks/support/methods.rb

Instance Method Summary collapse

Instance Method Details

#build_features_tableObject



28
29
30
# File 'lib/tasks/support/methods.rb', line 28

def build_features_table
  table_class.new(headings: table_header, rows: table_rows)
end

#clear_feature!(feature_name, strategy_name) ⇒ Object



21
22
23
24
25
26
# File 'lib/tasks/support/methods.rb', line 21

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

#status_label(enabled) ⇒ Object



6
7
8
# File 'lib/tasks/support/methods.rb', line 6

def status_label(enabled)
  enabled.nil? ? '' : (enabled ? 'ON' : 'OFF')
end

#switch_feature!(feature_name, strategy_name, value) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/tasks/support/methods.rb', line 10

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

  if strategy.switchable?
    strategy.switch!(feature.key, value)
  else
    raise "The :#{strategy_name} strategy doesn't support switching."
  end
end