Class: Decidim::Conferences::Admin::UpdateMediaLink

Inherits:
Decidim::Command show all
Defined in:
decidim-conferences/app/commands/decidim/conferences/admin/update_media_link.rb

Overview

A command with all the business logic when updating a conference speaker in the system.

Instance Method Summary collapse

Methods inherited from Decidim::Command

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

Constructor Details

#initialize(form, media_link) ⇒ UpdateMediaLink

Public: Initializes the command.

form - A form object with the params. media_link - The ConferenceSpeaker to update



13
14
15
16
# File 'decidim-conferences/app/commands/decidim/conferences/admin/update_media_link.rb', line 13

def initialize(form, media_link)
  @form = form
  @media_link = media_link
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 form was not valid and we could not proceed.

Returns nothing.



24
25
26
27
28
29
30
31
32
33
# File 'decidim-conferences/app/commands/decidim/conferences/admin/update_media_link.rb', line 24

def call
  return broadcast(:invalid) if form.invalid?
  return broadcast(:invalid) unless media_link

  transaction do
    update_media_link!
  end

  broadcast(:ok)
end