Class: Decidim::Admin::BulkUnreportUsers

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

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(current_user, reportables) ⇒ BulkUnreportUsers

Public: Initializes the command.

current_user - the user that performs the action reportables - all Decidim::Reportable selected by current_user



10
11
12
13
14
# File 'decidim-admin/app/commands/decidim/admin/bulk_unreport_users.rb', line 10

def initialize(current_user, reportables)
  @current_user = current_user
  @reportables = reportables
  @result = { ok: [], ko: [] }
end

Dynamic Method Handling

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

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid, together with the resource.

  • :invalid if the resource is not reported

Returns nothing.



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

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

  bulk_unreport_users!
  create_action_log if first_unreported

  broadcast(:ok, **result)
end