Class: Decidim::Pages::Admin::UpdatePage
- Inherits:
-
Command
- Object
- Command
- Decidim::Pages::Admin::UpdatePage
- Defined in:
- 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
-
#call ⇒ Object
Updates the page if valid.
-
#initialize(form, page) ⇒ UpdatePage
constructor
Initializes a UpdatePage Command.
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 'app/commands/decidim/pages/admin/update_page.rb', line 13 def initialize(form, page) @form = form @page = page end |
Instance Method Details
#call ⇒ Object
Updates the page if valid.
Broadcasts :ok if successful, :invalid otherwise.
21 22 23 24 25 26 |
# File 'app/commands/decidim/pages/admin/update_page.rb', line 21 def call return broadcast(:invalid) if @form.invalid? update_page broadcast(:ok) end |