Class: Decidim::Admin::UpdateResourcePermissions

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

Overview

This command gets called when permissions for a resource not related with a component are updated in the admin panel.

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(form, resource) ⇒ UpdateResourcePermissions

Public: Initializes the command.

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



12
13
14
15
# File 'decidim-admin/app/commands/decidim/admin/update_resource_permissions.rb', line 12

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Public: Sets the permissions for a resource.

Broadcasts :ok if created, :invalid otherwise.



20
21
22
23
24
25
26
27
28
# File 'decidim-admin/app/commands/decidim/admin/update_resource_permissions.rb', line 20

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

  transaction do
    update_permissions
  end

  broadcast(:ok)
end