Sha256: 0c43c8d8f2d60570b2a8e930667fd21f9ee6751605b3affa9382f43c0ecde7bf
Contents?: true
Size: 1.18 KB
Versions: 8
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Decidim module Proposals module Admin # A command with all the business logic when a user creates a new proposal. class CreateProposal < 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, together with the proposal. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? create_proposal broadcast(:ok) end private attr_reader :form, :proposal def create_proposal @proposal = Proposal.create!( title: form.title, body: form.body, category: form.category, scope: form.scope, feature: form.feature, address: form.address, latitude: form.latitude, longitude: form.longitude ) end end end end end
Version data entries
8 entries across 8 versions & 2 rubygems