Class: Decidim::Admin::UnpublishComponent

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

Overview

This command gets called when a component is unpublished from the admin panel.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(component, current_user) ⇒ UnpublishComponent

Public: Initializes the command.

component - The component to unpublish. current_user - the user performing the action



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

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

Public: Unpublishes the Component.

Broadcasts :ok if unpublished, :invalid otherwise.



19
20
21
22
23
# File 'decidim-admin/app/commands/decidim/admin/unpublish_component.rb', line 19

def call
  unpublish_component

  broadcast(:ok)
end