Sha256: ec8dfd92a2c8a62547ce20ded0c0b7a1fdc0f722f313db80b1264fad496a6d26

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

module Bushido
  class EnvsController < ApplicationController
    # PUT /bushido/envs/:id
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bushido-0.0.32 app/controllers/bushido/envs_controller.rb