Sha256: 5d9ec88626fd76217178966773cc2a1b073c03588f8c742b0301c80ea6c395d5
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when updating a category in the # system. class UpdateCategory < Decidim::Command attr_reader :category # Public: Initializes the command. # # category - the Category to update # form - A form object with the params. def initialize(category, form, user) @category = category @form = form @user = user 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? update_category broadcast(:ok) end private attr_reader :form def update_category Decidim.traceability.update!( category, @user, attributes ) end def attributes { name: form.name, weight: form.weight, parent_id: form.parent_id } end end end end
Version data entries
7 entries across 7 versions & 1 rubygems