Sha256: 39df314dff9bb64f0bc881964c9754ac4638bf1b6ba3b8cbee5e4ebb6d4874be
Contents?: true
Size: 976 Bytes
Versions: 8
Compression:
Stored size: 976 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when creating a scope type. class CreateScopeType < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(form, user) @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? create_scope_type broadcast(:ok) end private attr_reader :form def create_scope_type Decidim.traceability.create!( ScopeType, @user, name: form.name, organization: form.organization, plural: form.plural ) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems