Class: Toogle::FeaturesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/toogle/features_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/toogle/features_controller.rb', line 41

def destroy
  ::Feature.remove(params[:id])

  respond_to do |format|
    format.html do
      redirect_to features_url, status: :see_other
    end

    format.json do
      head :ok
    end
  end
end

#indexObject



3
4
5
6
7
8
9
10
# File 'app/controllers/toogle/features_controller.rb', line 3

def index
  @features = Toogle::Feature.all

  respond_to do |format|
    format.html
    format.json { render json: @features }
  end
end

#showObject



12
13
14
15
16
17
18
19
# File 'app/controllers/toogle/features_controller.rb', line 12

def show
  @definition = Toogle::Definition.find(params[:id])
  if @definition.nil?
    flash[:notice] = "No feature defintion with name \"#{params[:id]}\" found."
  end
  index
  render "index"
end

#updateObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/toogle/features_controller.rb', line 21

def update
  id = params[:id].to_sym

  if params[:state] == "enabled"
    ::Feature.enable(id)
  elsif params[:state] == "disabled"
    ::Feature.disable(id)
  end

  respond_to do |format|
    format.html do
      redirect_to features_url
    end

    format.json do
      head :ok
    end
  end
end