Sha256: 914d25d485fc6a7084ab3f6ef1c912dba79ce8d922020f34c828cd252f4254ed

Contents?: true

Size: 801 Bytes

Versions: 10

Compression:

Stored size: 801 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
          render_read_only if 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

10 entries across 10 versions & 1 rubygems

Version Path
flipper-ui-1.3.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.3.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.3.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.3.0.pre lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.2.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.2.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.2.0 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.1.2 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.1.1 lib/flipper/ui/actions/percentage_of_time_gate.rb
flipper-ui-1.1.0 lib/flipper/ui/actions/percentage_of_time_gate.rb