Class: Switchlet::FlagsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Switchlet::FlagsController
- Defined in:
- app/controllers/switchlet/flags_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/switchlet/flags_controller.rb', line 10 def create flag_name = params[:flag_name].strip description = params[:description]&.strip if flag_name.present? Switchlet.enable!(flag_name, description: description) redirect_to switchlet.flags_path, notice: "Flag '#{flag_name}' created and enabled" else redirect_to switchlet.flags_path, alert: "Flag name cannot be empty" end end |
#destroy ⇒ Object
43 44 45 46 47 |
# File 'app/controllers/switchlet/flags_controller.rb', line 43 def destroy flag_name = params[:name] Switchlet.delete!(flag_name) redirect_to switchlet.flags_path, notice: "Flag '#{flag_name}' deleted" end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/switchlet/flags_controller.rb', line 5 def index @flags = Switchlet.list end |
#update ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/switchlet/flags_controller.rb', line 21 def update flag_name = params[:name] # Handle toggle action if params[:action_type] == 'toggle' current_state = Switchlet.enabled?(flag_name) if current_state Switchlet.disable!(flag_name) else Switchlet.enable!(flag_name) end redirect_to switchlet.flags_path, notice: "Flag '#{flag_name}' #{current_state ? 'disabled' : 'enabled'}" # Handle description update else description = params[:description] Switchlet.update!(flag_name, description: description) redirect_to switchlet.flags_path, notice: "Description updated for '#{flag_name}'" end end |