Sha256: 8cbf0272f22b1699a91ed691b01f28a330224a7be0ec8496cd92dbb2c57623d3

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    class CreateEditorImage < Rectify::Command
      # Creates a blueprint.
      #
      # form - The form with the data.
      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?

        image = EditorImage.create!(
          image: form.image,
          path: form.path,
          decidim_author_id: form.current_user.id,
          organization: form.current_organization
        )
        broadcast(:ok, image)
      end

      attr_reader :form
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.6.0 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.5.1 app/commands/decidim/decidim_awesome/create_editor_image.rb