Class: Decidim::Admin::UnblockUser

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

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(blocked_user, current_user) ⇒ UnblockUser

Public: Initializes the command.

blocked_user - the user that is unblocked current_user - the user performing the action



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

def initialize(blocked_user, current_user)
  @blocked_user = blocked_user
  @current_user = current_user
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.



21
22
23
24
25
26
# File 'decidim-admin/app/commands/decidim/admin/unblock_user.rb', line 21

def call
  return broadcast(:invalid) unless @blocked_user.blocked?

  unblock!
  broadcast(:ok, @blocked_user)
end