Class: Flipper::UI::Actions::GroupsGate

Inherits:
Flipper::UI::Action show all
Defined in:
lib/flipper/ui/actions/groups_gate.rb

Constant Summary

Constants inherited from Flipper::UI::Action

Flipper::UI::Action::VALID_REQUEST_METHOD_NAMES

Instance Attribute Summary

Attributes inherited from Flipper::UI::Action

#flipper, #request

Instance Method Summary collapse

Methods inherited from Flipper::UI::Action

#breadcrumb, #csrf_input_tag, #halt, #header, #initialize, #json_response, public_path, #public_path, #redirect_to, regex, #request_method_name, route, #run, run, #run_other_action, #script_name, #status, #valid_request_method?, #view, #view_response, #view_with_layout, #view_without_layout, views_path, #views_path

Constructor Details

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

Instance Method Details

#getObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/flipper/ui/actions/groups_gate.rb', line 10

def get
  feature_name = Rack::Utils.unescape(request.path.split('/')[-2])
  feature = flipper[feature_name.to_sym]
  @feature = Decorators::Feature.new(feature)

  breadcrumb "Home", "/"
  breadcrumb "Features", "/features"
  breadcrumb @feature.key, "/features/#{@feature.key}"
  breadcrumb "Add Group"

  view_response :add_group
end

#postObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/flipper/ui/actions/groups_gate.rb', line 23

def post
  feature_name = Rack::Utils.unescape(request.path.split('/')[-2])
  feature = flipper[feature_name.to_sym]
  value = params["value"]

  case params["operation"]
  when "enable"
    feature.enable_group value
  when "disable"
    feature.disable_group value
  end

  redirect_to("/features/#{feature.key}")
rescue Flipper::GroupNotRegistered => e
  error = Rack::Utils.escape("The group named #{value.inspect} has not been registered.")
  redirect_to("/features/#{feature.key}/groups?error=#{error}")
end