Sha256: 584c14e4e4c0549f9589c048e3198647a5c75723e8820139022897bb70b2c8e6

Contents?: true

Size: 498 Bytes

Versions: 7

Compression:

Stored size: 498 Bytes

Contents

# frozen_string_literal: true
module Decidim
  # A command to remove a role from a given User.
  class RemoveUserRole < Rectify::Command
    # Public: Initializes the command.
    #
    # form - A form object with the params.
    def initialize(user, role)
      @user = user
      @role = role
    end

    def call
      return broadcast(:invalid) unless user

      user.roles.delete(role.to_s)
      user.save!

      broadcast(:ok)
    end

    private

    attr_reader :user, :role
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.1.0 app/commands/decidim/remove_user_role.rb
decidim-core-0.0.8.1 app/commands/decidim/remove_user_role.rb
decidim-core-0.0.7 app/commands/decidim/remove_user_role.rb
decidim-core-0.0.6 app/commands/decidim/remove_user_role.rb
decidim-core-0.0.5 app/commands/decidim/remove_user_role.rb
decidim-core-0.0.3 app/commands/decidim/remove_user_role.rb
decidim-core-0.0.2 app/commands/decidim/remove_user_role.rb