Sha256: c6c41ec0c1848c07b0e7443db93fa4aac1b23c8fc8748f335ca28c5e818a1a83
Contents?: true
Size: 913 Bytes
Versions: 18
Compression:
Stored size: 913 Bytes
Contents
# frozen_string_literal: true module Decidim # A command with all the business logic to create an editor image. class CreateEditorImage < Decidim::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 was not valid and we could not proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? transaction do create_editor_image end broadcast(:ok, @editor_image) end private attr_reader :form def create_editor_image @editor_image = EditorImage.create!( decidim_author_id: form.current_user.id, organization: form.organization, file: form.file ) end end end
Version data entries
18 entries across 18 versions & 1 rubygems