Sha256: 41c9ed00e4a339572c5e4ed00e99fc6c7bb7e0377d4b11ffbefd485c785f24c5

Contents?: true

Size: 1008 Bytes

Versions: 6

Compression:

Stored size: 1008 Bytes

Contents

module FeatureGate
  class GatedFeaturesController < ApplicationController
    before_filter :ensure_feature_gate_control_allowed
    layout 'feature_gate/application'

    def index
      @closed_gates = FeatureGate::GatedFeature.closed
      @opened_gates = FeatureGate::GatedFeature.opened
      @stale_gates = FeatureGate::GatedFeature.stale.order(:updated_at)
    end

    def update
      gate = FeatureGate::GatedFeature.find(params[:id])
      if params[:gated] == 'true'
        gate.gate_feature!
        flash[:notice] = 'Feature has been gated'
      else
        gate.deploy_feature!
        flash[:success] = 'Feature is live!'
      end

      redirect_to gated_features_path
    end

    private

    define_method(:feature_gate_control_allowed?) do
      true
    end unless method_defined? :feature_gate_control_allowed?

    def ensure_feature_gate_control_allowed
      return if feature_gate_control_allowed?
      raise ActionController::RoutingError.new('Not Found')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
feature_gate-0.1.9 app/controllers/feature_gate/gated_features_controller.rb
feature_gate-0.1.8 app/controllers/feature_gate/gated_features_controller.rb
feature_gate-0.1.7 app/controllers/feature_gate/gated_features_controller.rb
feature_gate-0.1.6 app/controllers/feature_gate/gated_features_controller.rb
feature_gate-0.1.5 app/controllers/feature_gate/gated_features_controller.rb
feature_gate-0.1.4 app/controllers/feature_gate/gated_features_controller.rb