Sha256: 0c9e9f7e1582fb1758f534609c56ef946f38e405c3946afc35e02e9c1bb22963

Contents?: true

Size: 861 Bytes

Versions: 3

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryDocuments
    module Admin
      # A command with all the business logic when a user updates a suggestion note.
      class UpdateSuggestionNote < Decidim::Command
        # Public: Initializes the command.
        #
        # form         - A form object with the params.
        # note - the suggestion note to update.
        def initialize(notes_form, note)
          @notes_form = notes_form
          @note = note
        end

        def call
          return broadcast(:invalid) if notes_form.invalid?

          update_suggestion_note

          broadcast(:ok, note)
        end

        private

        attr_reader :notes_form, :note, :suggestion

        def update_suggestion_note
          note.body = notes_form.body
          note.save!
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-participatory_documents-0.2.2 app/commands/decidim/participatory_documents/admin/update_suggestion_note.rb
decidim-participatory_documents-0.2.1 app/commands/decidim/participatory_documents/admin/update_suggestion_note.rb
decidim-participatory_documents-0.2.0 app/commands/decidim/participatory_documents/admin/update_suggestion_note.rb