Sha256: d8a0a0e6176632a3f6b746ab127e957d3d4c70d4564661cbe9af011c13396090
Contents?: true
Size: 916 Bytes
Versions: 3
Compression:
Stored size: 916 Bytes
Contents
# frozen_string_literal: true module Decidim module ActionDelegator module Admin class CreatePonderation < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(form) @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? create_ponderation broadcast(:ok, ponderation) end private attr_reader :form, :ponderation def create_ponderation @ponderation = Ponderation.create!(name: form.name, weight: form.weight, setting: form.setting) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems