Sha256: 57d4e8353728dff0f55ae671a049e005bd74a667d3d9edf42c8c1f59d2ebae4d

Contents?: true

Size: 820 Bytes

Versions: 9

Compression:

Stored size: 820 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.new(
          path: form.path,
          decidim_author_id: form.current_user.id,
          organization: form.organization,
          image: form.image
        )

        image.save!
        broadcast(:ok, image)
      end

      attr_reader :form
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.7.2 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.7.0 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.7 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.6 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.5 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.4 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.3 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.2 app/commands/decidim/decidim_awesome/create_editor_image.rb
decidim-decidim_awesome-0.6.1 app/commands/decidim/decidim_awesome/create_editor_image.rb