Sha256: c95b734bc30bdfc73fbbbe013c0c644a82eb2ca4287732ce8da49201b2d78930

Contents?: true

Size: 779 Bytes

Versions: 19

Compression:

Stored size: 779 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
          feature = flipper[feature_name]
          @feature = Decorators::Feature.new(feature)

          begin
            feature.enable_percentage_of_time params['value']
          rescue ArgumentError => exception
            error = Rack::Utils.escape("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

19 entries across 19 versions & 1 rubygems

Version Path
flipper-ui-0.21.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.21.0.rc2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.21.0.rc1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.4 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.3 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.0.beta3 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.0.beta2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.20.0.beta1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.19.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.19.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.18.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.17.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.17.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.16.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.16.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.16.0 lib/flipper/ui/actions/percentage_of_time_gate.rb