Sha256: da9e315eedcf6d7a12d21eb6138759f119a94c5b4098c0d7a684986a87ea616d
Contents?: true
Size: 972 Bytes
Versions: 8
Compression:
Stored size: 972 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when creating an area type. class CreateAreaType < 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_area_type broadcast(:ok) end private attr_reader :form def create_area_type Decidim.traceability.create!( AreaType, @user, name: form.name, organization: form.organization, plural: form.plural ) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems