Class: Decidim::Admin::UpdateFeaturePermissions

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/admin/update_feature_permissions.rb

Overview

This command gets called when permissions for a feature are updated in the admin panel.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form, feature) ⇒ UpdateFeaturePermissions

Public: Initializes the command.

form - The form from which the data in this feature comes from. feature - The feature to update.



14
15
16
17
# File 'app/commands/decidim/admin/update_feature_permissions.rb', line 14

def initialize(form, feature)
  @form = form
  @feature = feature
end

Instance Attribute Details

#featureObject (readonly)

Returns the value of attribute feature.



8
9
10
# File 'app/commands/decidim/admin/update_feature_permissions.rb', line 8

def feature
  @feature
end

#formObject (readonly)

Returns the value of attribute form.



8
9
10
# File 'app/commands/decidim/admin/update_feature_permissions.rb', line 8

def form
  @form
end

Instance Method Details

#callObject

Public: Sets the permissions for a feature.

Broadcasts :ok if created, :invalid otherwise.



22
23
24
25
26
27
28
29
30
31
# File 'app/commands/decidim/admin/update_feature_permissions.rb', line 22

def call
  return broadcast(:invalid) unless @form.valid?

  transaction do
    update_permissions
    run_hooks
  end

  broadcast(:ok)
end