Sha256: b44fec47252f280ad4847848020e2a12cb5cf3ad16c08ca2298fa6e3887ef908

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 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
    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

1 entries across 1 versions & 1 rubygems

Version Path
feature_gate-0.1.3 app/controllers/feature_gate/gated_features_controller.rb