Class: Bushido::EnvsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/bushido/envs_controller.rb

Instance Method Summary collapse

Instance Method Details

#updateObject

PUT /bushido/envs/:id



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/bushido/envs_controller.rb', line 4

def update
  if ENV["BUSHIDO_APP_KEY"] != params[:key] or params[:id] == "BUSHIDO_KEY"
    respond_to do |format|
      format.html { render :layout => false, :text => true, :status => :forbidden }
      format.json { render :status => :unprocessable_entity }
      return
    end
  end

  ENV[params[:id]] = params[:value]
  @value = ENV[params[:id]]
  
  respond_to do |format|
    if @value != ENV[params[:id]]
      format.html{render :layout => false, :text => true, :status => :unprocessable_entity}
      format.json{render :status => :unprocessable_entity}
    else
      puts "Firing update hooks method from controller"
      Bushido::Hooks.fire(params[:id], {params[:id] => ENV[params[:id]]})
      format.html{render :text => true}
      format.json{render :json => {params[:id] => ENV[params[:id]]}}
    end
  end
end