Sha256: 09c0a977b6a3b676edd390289bd0d12b2409c063673646237afc05cc2a8d1df9
Contents?: true
Size: 981 Bytes
Versions: 5
Compression:
Stored size: 981 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when creating a static page. class CreateStaticPage < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(form) @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? create_page broadcast(:ok) end private attr_reader :form def create_page Decidim.traceability.create!( StaticPage, form.current_user, title: form.title, slug: form.slug, content: form.content, organization: form.organization ) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems