Sha256: 40fa3c3026747eccf6a4e78b0a31778dd2d3f3ad8443407c2cb107e1df29c570

Contents?: true

Size: 614 Bytes

Versions: 3

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Notify
    class DeleteNote < Rectify::Command
      # Public: Initializes the command.
      #
      def initialize(id)
        @id = id
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid.
      # - :invalid if we couldn't proceed.
      #
      # Returns nothing.
      def call
        note = Note.for(current_component).find(@id)
        note.destroy!

        broadcast(:ok)
      rescue ActiveRecord::ActiveRecordError => e
        broadcast(:invalid, e.message)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-notify-0.5 app/commands/decidim/notify/delete_note.rb
decidim-notify-0.4 app/commands/decidim/notify/delete_note.rb
decidim-notify-0.3 app/commands/decidim/notify/delete_note.rb