class Flipper::Api::V1::Actions::PercentageOfActorsGate

Public Instance Methods

delete() click to toggle source
# File lib/flipper/api/v1/actions/percentage_of_actors_gate.rb, line 24
def delete
  feature = flipper[feature_name]
  feature.disable_percentage_of_actors
  decorated_feature = Decorators::Feature.new(feature)
  json_response(decorated_feature.as_json, 200)
end
post() click to toggle source
# File lib/flipper/api/v1/actions/percentage_of_actors_gate.rb, line 13
def post
  if percentage < 0 || percentage > 100
    json_error_response(:percentage_invalid)
  end

  feature = flipper[feature_name]
  feature.enable_percentage_of_actors(percentage)
  decorated_feature = Decorators::Feature.new(feature)
  json_response(decorated_feature.as_json, 200)
end

Private Instance Methods

percentage() click to toggle source
# File lib/flipper/api/v1/actions/percentage_of_actors_gate.rb, line 37
def percentage
  @percentage ||= begin
    unless percentage_param.match(/\d/)
      raise ArgumentError, "invalid numeric value: #{percentage_param}"
    end

    Flipper::Types::Percentage.new(percentage_param).value
  rescue ArgumentError, TypeError
    -1
  end
end
percentage_param() click to toggle source
# File lib/flipper/api/v1/actions/percentage_of_actors_gate.rb, line 33
def percentage_param
  @percentage_param ||= params['percentage'].to_s
end