Sha256: abd5177d811ad378b87e6b92e4e48a3dbcd7783cbce548ff865a462cc02e10a5

Contents?: true

Size: 819 Bytes

Versions: 13

Compression:

Stored size: 819 Bytes

Contents

require 'flipper/ui/action'
require 'flipper/ui/decorators/feature'

module Flipper
  module UI
    module Actions
      class PercentageOfTimeGate < UI::Action
        include FeatureNameFromRoute

        route %r{\A/features/(?<feature_name>.*)/percentage_of_time/?\Z}

        def post
          read_only if Flipper::UI.configuration.read_only

          feature = flipper[feature_name]
          @feature = Decorators::Feature.new(feature)

          begin
            feature.enable_percentage_of_time params['value']
          rescue ArgumentError => exception
            error = "Invalid percentage of time value: #{exception.message}"
            redirect_to("/features/#{@feature.key}?error=#{error}")
          end

          redirect_to "/features/#{@feature.key}"
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flipper-ui-1.0.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.0.0.pre lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.28.3 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.28.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.28.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.28.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.27.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.27.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.26.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.26.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.26.0.rc2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.26.0.rc1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.25.4 lib/flipper/ui/actions/percentage_of_time_gate.rb