Class: Decidim::ActionDelegator::Admin::FixResourcePermissions

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

Instance Method Summary collapse

Constructor Details

#initialize(resources) ⇒ FixResourcePermissions

Returns a new instance of FixResourcePermissions.



7
8
9
10
# File 'app/commands/decidim/action_delegator/admin/fix_resource_permissions.rb', line 7

def initialize(resources)
  @resources = resources
  @errors = []
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form wasn’t valid and we couldn’t proceed.

Returns nothing.



18
19
20
21
22
23
24
25
26
# File 'app/commands/decidim/action_delegator/admin/fix_resource_permissions.rb', line 18

def call
  return broadcast(:invalid) if resources.blank?

  update_permissions

  return broadcast(:invalid) if errors.any?

  broadcast(:ok)
end