Class: Admin::FeatureFlagsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/feature_flags_controller.rb

Defined Under Namespace

Classes: Collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



7
8
9
# File 'app/controllers/admin/feature_flags_controller.rb', line 7

def collection
  @collection
end

#feature_flagObject (readonly)

Returns the value of attribute feature_flag.



7
8
9
# File 'app/controllers/admin/feature_flags_controller.rb', line 7

def feature_flag
  @feature_flag
end

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/admin/feature_flags_controller.rb', line 25

def create
  @feature_flag = FeatureFlag.build(key: params.expect(feature_flag: [:key]).fetch(:key, nil))

  if feature_flag.save
    redirect_to(admin_feature_flag_path(feature_flag), status: :see_other)
  else
    render(:new, locals: { feature_flag: }, status: :unprocessable_content)
  end
end

#destroyObject



41
42
43
44
45
# File 'app/controllers/admin/feature_flags_controller.rb', line 41

def destroy
  feature_flag.destroy

  redirect_to(admin_feature_flags_path, status: :see_other)
end

#indexObject



9
10
11
12
13
# File 'app/controllers/admin/feature_flags_controller.rb', line 9

def index
  @collection = Collection.with_params(params).apply(FeatureFlag.all)

  render locals: { collection: }
end

#newObject



19
20
21
22
23
# File 'app/controllers/admin/feature_flags_controller.rb', line 19

def new
  @feature_flag = FeatureFlag.build

  render locals: { feature_flag: }
end

#showObject



15
16
17
# File 'app/controllers/admin/feature_flags_controller.rb', line 15

def show
  render locals: { feature_flag:, groups: Flipper.group_names }
end

#updateObject



35
36
37
38
39
# File 'app/controllers/admin/feature_flags_controller.rb', line 35

def update
  feature_flag.update(feature_flag_params)

  redirect_to(admin_feature_flags_path, status: :see_other)
end