Sha256: deb4c581bdc5c0e0a1befe483d1a8cfe5fb58d46fa7601c064ada728e8d134f2
Contents?: true
Size: 775 Bytes
Versions: 19
Compression:
Stored size: 775 Bytes
Contents
# frozen_string_literal: true module Decidim # This command updates the user's interests. class UpdateUserInterests < Decidim::Command # Updates a user's intersts. # # user - The user to be updated. # form - The form with the data. def initialize(user, form) @user = user @form = form end def call return broadcast(:invalid) unless @form.valid? update_interests @user.save! broadcast(:ok) end private def update_interests @user.extended_data ||= {} @user.extended_data["interested_scopes"] = selected_scopes_ids end def selected_scopes_ids @form.scopes.map do |scope| next unless scope.checked? scope.id.to_i end.compact end end end
Version data entries
19 entries across 19 versions & 1 rubygems