Sha256: 0db766564933fe89d8a54172732ac68a3e9c6a43cadf764818a2f5dd7b628958

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

module Flipflop
  class StrategiesController < ApplicationController
    include ActionController::RequestForgeryProtection

    def update
      FeatureSet.current.switch!(feature_key, strategy_key, enable?)
      redirect_to(features_url)
    end

    def destroy
      FeatureSet.current.clear!(feature_key, strategy_key)
      redirect_to(features_url)
    end

    private

    # Modeled after ActiveModel::Type::Boolean, but only returns boolean values
    # (never nil) and checks for true values, because that's what earlier
    # versions of Flipflop did.
    ENABLE_VALUES = %w(1 on ON t T).to_set.freeze

    def enable?
      ENABLE_VALUES.include?(params[:commit])
    end

    def feature_key
      params[:feature_id].to_sym
    end

    def strategy_key
      params[:id]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flipflop-2.7.0 app/controllers/flipflop/strategies_controller.rb
flipflop-2.6.0 app/controllers/flipflop/strategies_controller.rb
flipflop-2.5.0 app/controllers/flipflop/strategies_controller.rb
flipflop-2.4.0 app/controllers/flipflop/strategies_controller.rb