Class: Decidim::Admin::ReorderComponents

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

Overview

A command that reorders a collection of components

Instance Method Summary collapse

Constructor Details

#initialize(components, order) ⇒ ReorderComponents

Public: Initializes the command.

components - the components to reorder order - an Array holding the order of IDs of the components



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

def initialize(components, order)
  @components = components
  @order = order
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the data was not valid and we could not proceed.

Returns nothing.



22
23
24
25
26
27
# File 'app/commands/decidim/admin/reorder_components.rb', line 22

def call
  return broadcast(:invalid) unless valid_params?

  reorder_components
  broadcast(:ok)
end