Sha256: 417c3a71b27b43febe7a0c37a40bda840100f0bde3fb057bebd345bf43a0efc9
Contents?: true
Size: 1011 Bytes
Versions: 36
Compression:
Stored size: 1011 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when updating a scope type. class UpdateScopeType < Rectify::Command # Public: Initializes the command. # # scope_type - The ScopeType to update # form - A form object with the params. def initialize(scope_type, form) @scope_type = scope_type @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? update_scope_type broadcast(:ok) end private attr_reader :form def update_scope_type @scope_type.update_attributes!(attributes) end def attributes { name: form.name, plural: form.plural } end end end end
Version data entries
36 entries across 36 versions & 2 rubygems