Sha256: b3a8c5c5d2abc7b2bb946db78fce6ef78f482f257f8aa34925fed622a934ece9
Contents?: true
Size: 908 Bytes
Versions: 7
Compression:
Stored size: 908 Bytes
Contents
# frozen_string_literal: true module Decidim module Pages module Admin # This command is executed when the user changes a Page from the admin # panel. class UpdatePage < Rectify::Command # Initializes a UpdatePage Command. # # form - The form from which to get the data. # page - The current instance of the page to be updated. def initialize(form, page) @form = form @page = page end # Updates the page if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if @form.invalid? update_page broadcast(:ok) end private def update_page @page.update_attributes!( title: @form.title, body: @form.body ) end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems