Sha256: 8284f23d194c852d9a58cd32af4934f46a489a56129c0c2bd9f4ef7c7fdd0939
Contents?: true
Size: 1003 Bytes
Versions: 54
Compression:
Stored size: 1003 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when updating a static page. class UpdateStaticPage < Rectify::Command # Public: Initializes the command. # # page - The StaticPage to update # form - A form object with the params. def initialize(page, form) @page = page @form = form end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? update_page broadcast(:ok) end private attr_reader :form def update_page @page.update_attributes!(attributes) end def attributes { title: form.title, slug: form.slug, content: form.content } end end end end
Version data entries
54 entries across 54 versions & 2 rubygems