Sha256: 7eff318b111909396c248199642800eb3c25957bd8c9c2ccbcd8eb64444c65be

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

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

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

          transaction do
            update_external_event!
          end

          broadcast(:ok, @event)
        end

        private

        attr_reader :external_event, :form

        def update_external_event!
          external_event.update! attributes
        end

        def attributes
          {
            title: form.title,
            start_at: form.start_at,
            end_at: form.end_at,
            url: form.url,
            organization: current_organization,
            author: 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/update_external_event.rb
decidim-calendar-0.13.1.3 app/commands/decidim/calendar/admin/update_external_event.rb