Sha256: 96e378a0cdba56166c342a8a9e1b35080c52da1cfed4e342bef9d29e5b0dd440

Contents?: true

Size: 814 Bytes

Versions: 20

Compression:

Stored size: 814 Bytes

Contents

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

module Flipper
  module UI
    module Actions
      class PercentageOfActorsGate < UI::Action
        route %r{features/[^/]*/percentage_of_actors/?\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_actors params["value"]
          rescue ArgumentError => exception
            error = Rack::Utils.escape("Invalid percentage of actors 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_actors_gate.rb
flipper-ui-0.10.1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.10.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.9.2 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.9.1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.9.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.9.0.beta1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.8.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.5 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.4 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.3 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.2 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.0.beta6 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.0.beta5 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.7.0.beta4 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.2.0.beta5 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.2.0.beta4 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.2.0.beta3 lib/flipper/ui/actions/percentage_of_actors_gate.rb