Sha256: 127730f16d3c2ce91764bf3b5b1a6c11e62e788c1f1b4118a90bc5ac369e67f4

Contents?: true

Size: 847 Bytes

Versions: 14

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command with all the business logic when rejecting a user_group.
    class RejectUserGroup < Rectify::Command
      # Public: Initializes the command.
      #
      # user_group - The user_group to reject
      def initialize(user_group)
        @user_group = user_group
      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) unless @user_group.valid?
        reject_user_group
        broadcast(:ok)
      end

      private

      def reject_user_group
        @user_group.update_attributes!(rejected_at: Time.current, verified_at: nil)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-admin-0.9.3 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.9.2 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.9.1 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.9.0 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.8.4 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.8.3 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.8.2 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.8.1 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.8.0 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.7.4 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.7.3 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.7.2 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.7.1 app/commands/decidim/admin/reject_user_group.rb
decidim-admin-0.7.0 app/commands/decidim/admin/reject_user_group.rb