Sha256: d3eb7394d1533bd24f38a1823753f540a7f7a93e8f2a918ebbaf935a8d3348f4
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 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? update_organization broadcast(:ok) end private attr_reader :form, :organization def update_organization organization.update_attributes!(attributes) end def attributes { name: form.name, twitter_handler: form.twitter_handler, description: form.description, welcome_text: form.welcome_text, homepage_image: form.homepage_image || organization.homepage_image, logo: form.logo || organization.logo, default_locale: form.default_locale, show_statistics: form.show_statistics } end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decidim-admin-0.0.2 | app/commands/decidim/admin/update_organization.rb |
decidim-0.0.2 | decidim-admin/app/commands/decidim/admin/update_organization.rb |