Class: FeatureGate::GatedFeaturesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/feature_gate/gated_features_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/feature_gate/gated_features_controller.rb', line 25

def destroy
  gate = FeatureGate::GatedFeature.find(params[:id])
  if gate.destroyable?
    gate.destroy!
    flash[:success] = "#{gate.name} has been deleted"
  else
    flash[:error] = "#{gate.name} is currently being used in the codebase, execute `feature_gate_cleaner #{gate.name}` in the terminal to remove all references to #{gate.name}"
  end

  redirect_to gated_features_path
end

#indexObject



6
7
8
9
10
# File 'app/controllers/feature_gate/gated_features_controller.rb', line 6

def index
  @closed_gates = FeatureGate::GatedFeature.closed
  @opened_gates = FeatureGate::GatedFeature.opened
  @stale_gates = FeatureGate::GatedFeature.stale.order(:updated_at)
end

#updateObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/feature_gate/gated_features_controller.rb', line 12

def update
  gate = FeatureGate::GatedFeature.find(params[:id])
  if params[:gated] == 'true'
    gate.gate_feature!
    flash[:notice] = "#{gate.name} has been gated"
  else
    gate.deploy_feature!
    flash[:success] = "#{gate.name} is live!"
  end

  redirect_to gated_features_path
end