Sha256: a7978f561b2879d793473dbe2f1d94dc5013fa1d605507090a1122c37686cddb
Contents?: true
Size: 712 Bytes
Versions: 38
Compression:
Stored size: 712 Bytes
Contents
# frozen_string_literal: true module Decidim # This command updates the user's interests. class UpdateUserInterests < Rectify::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.select(&:checked).map(&:id) end end end
Version data entries
38 entries across 38 versions & 1 rubygems