Class: Admin::FeaturesController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/generators/open_loam/install/templates/admin/features_controller.rb

Overview

Feature flags (OpenLoam::Features). Structural and privileged, so manager-only, like Settings. Everything routes through OpenLoam::Features; the admin toggles the CURRENT tenant's override, and Reset drops it back to the declared / global state. Global (app-wide) flips are a deploy concern, not this screen.

Constant Summary

Constants included from Pagination

Pagination::PER_PAGE

Instance Method Summary collapse

Methods inherited from BaseController

skip_authorization!

Methods included from Pagination

#paginate

Instance Method Details

#disable ⇒ Object



25
26
27
28
# File 'lib/generators/open_loam/install/templates/admin/features_controller.rb', line 25

def disable
  OpenLoam::Features.disable(params[:name])
  redirect_to admin_features_path, notice: "#{params[:name]} disabled for this tenant."
end

#enable ⇒ Object



20
21
22
23
# File 'lib/generators/open_loam/install/templates/admin/features_controller.rb', line 20

def enable
  OpenLoam::Features.enable(params[:name])
  redirect_to admin_features_path, notice: "#{params[:name]} enabled for this tenant."
end

#index ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/open_loam/install/templates/admin/features_controller.rb', line 9

def index
  @flags = OpenLoam::Features.declared.map do |name|
    {
      name: name,
      on: OpenLoam::Features.on?(name),
      overridden: OpenLoam::Features.overridden?(name),
      description: OpenLoam::Features.description(name)
    }
  end
end

#reset ⇒ Object



30
31
32
33
# File 'lib/generators/open_loam/install/templates/admin/features_controller.rb', line 30

def reset
  OpenLoam::Features.reset(params[:name])
  redirect_to admin_features_path, notice: "#{params[:name]} reset to the default."
end