Class: Decidim::Admin::HideResource
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::HideResource
- Defined in:
- app/commands/decidim/admin/hide_resource.rb
Overview
A command with all the business logic when a user hides a resource.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(reportable, current_user) ⇒ HideResource
constructor
Public: Initializes the command.
Constructor Details
#initialize(reportable, current_user) ⇒ HideResource
Public: Initializes the command.
reportable - A Decidim::Reportable current_user - the user that performs the action
11 12 13 14 |
# File 'app/commands/decidim/admin/hide_resource.rb', line 11 def initialize(reportable, current_user) @reportable = reportable @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the resource.
-
:invalid if the resource is already hidden
Returns nothing.
22 23 24 25 26 27 28 29 30 |
# File 'app/commands/decidim/admin/hide_resource.rb', line 22 def call return broadcast(:invalid) unless hideable? hide! broadcast(:ok, @reportable) end |