Class: Decidim::Pages::Admin::UpdatePage

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

Overview

This command is executed when the user changes a Page 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(form, page) ⇒ UpdatePage

Initializes a UpdatePage Command.

form - The form from which to get the data. page - The current instance of the page to be updated.



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

def initialize(form, page)
  @form = form
  @page = page
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Updates the page if valid.

Broadcasts :ok if successful, :invalid otherwise.



21
22
23
24
25
26
# File 'decidim-pages/app/commands/decidim/pages/admin/update_page.rb', line 21

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

  update_page
  broadcast(:ok)
end