Sha256: 3b361edb57c2deaa70fdb64c9856c8c127e6c1efc01b867d892762aa9d462216

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Calendar
    module Admin
      class CreateExternalEvent < Rectify::Command
        def initialize(form)
          @form = form
        end

        def call
          return broadcast(:invalid) if form.invalid?

          transaction do
            create_event
          end

          broadcast(:ok, @event)
        end

        private

        attr_reader :form

        def create_event
          @event = ExternalEvent.create(
            organization: form.current_organization,
            title: form.title,
            start_at: form.start_at,
            end_at: form.end_at,
            url: form.url,
            author: form.current_user
          )
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-calendar-0.19.0 app/commands/decidim/calendar/admin/create_external_event.rb
decidim-calendar-0.13.1.3 app/commands/decidim/calendar/admin/create_external_event.rb