Sha256: 756f490398e96cc64ab30fb3e6221827d8a1c8c231683b5412c931f9b4762087
Contents?: true
Size: 1.49 KB
Versions: 16
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic for updating the current # organization. class UpdateOrganization < Rectify::Command # Public: Initializes the command. # # organization - The Organization that will be updated. # form - A form object with the params. def initialize(organization, form) @organization = organization @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? return broadcast(:ok, @organization) if update_organization broadcast(:invalid) end private attr_reader :form, :organization def update_organization @organization = Decidim.traceability.update!( @organization, form.current_user, attributes ) end def attributes { name: form.name, default_locale: form.default_locale, reference_prefix: form.reference_prefix, twitter_handler: form.twitter_handler, facebook_handler: form.facebook_handler, instagram_handler: form.instagram_handler, youtube_handler: form.youtube_handler, github_handler: form.github_handler } end end end end
Version data entries
16 entries across 16 versions & 1 rubygems