Class: Decidim::Admin::HideResource

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-admin/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

Constructor Details

#initialize(reportable) ⇒ HideResource

Public: Initializes the command.

reportable - A Decidim::Reportable



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

def initialize(reportable)
  @reportable = reportable
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

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

  • :invalid if the resource is already hidden

Returns nothing.



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

def call
  return broadcast(:invalid) unless hideable?

  hide!
  broadcast(:ok, @reportable)
end