Class: Decidim::Admin::ReorderComponents

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

Overview

A command that reorders a collection of components

Instance Method Summary collapse

Methods inherited from Command

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

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 'decidim-admin/app/commands/decidim/admin/reorder_components.rb', line 11

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

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

Returns nothing.



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

def call
  return broadcast(:invalid) unless valid_params?

  reorder_components
  broadcast(:ok)
end