Sha256: bf4396ba46b7184d2942d02aed2c09065498312deae643b9d3259e5d090f450b

Contents?: true

Size: 806 Bytes

Versions: 20

Compression:

Stored size: 806 Bytes

Contents

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

module Flipper
  module UI
    module Actions
      class PercentageOfTimeGate < UI::Action
        route %r{features/[^/]*/percentage_of_time/?\Z}

        def post
          feature_name = Rack::Utils.unescape(request.path.split("/")[-2])
          feature = flipper[feature_name.to_sym]
          @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

20 entries across 20 versions & 1 rubygems

Version Path
flipper-ui-0.10.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.10.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.10.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.9.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.9.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.9.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.9.0.beta1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.8.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.5 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.4 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.3 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.0.beta6 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.0.beta5 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.7.0.beta4 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.2.0.beta5 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.2.0.beta4 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-0.2.0.beta3 lib/flipper/ui/actions/percentage_of_time_gate.rb