Class: Flipper::Api::V1::Actions::PercentageOfTimeGate

Inherits:
Action
  • Object
show all
Includes:
FeatureNameFromRoute
Defined in:
lib/flipper/api/v1/actions/percentage_of_time_gate.rb

Constant Summary

Constants inherited from Action

Action::VALID_REQUEST_METHOD_NAMES

Instance Attribute Summary

Attributes inherited from Action

#flipper, #request

Instance Method Summary collapse

Methods inherited from Action

#halt, #header, #initialize, #json_error_response, #json_response, route, route_match?, route_regex, #run, run, #run_other_action, #status

Constructor Details

This class inherits a constructor from Flipper::Api::Action

Instance Method Details

#deleteObject



24
25
26
27
28
29
30
# File 'lib/flipper/api/v1/actions/percentage_of_time_gate.rb', line 24

def delete
  feature = flipper[feature_name]
  feature.disable_percentage_of_time

  decorated_feature = Decorators::Feature.new(feature)
  json_response(decorated_feature.as_json, 200)
end

#postObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/flipper/api/v1/actions/percentage_of_time_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_time(percentage)
  decorated_feature = Decorators::Feature.new(feature)
  json_response(decorated_feature.as_json, 200)
end