Class: Decidim::Admin::OfficializeUser
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::OfficializeUser
- Defined in:
- app/commands/decidim/admin/officialize_user.rb
Overview
A command with all the business logic when officializing a user.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form) ⇒ OfficializeUser
constructor
Public: Initializes the command.
Constructor Details
#initialize(form) ⇒ OfficializeUser
Public: Initializes the command.
form - The officialization form.
10 11 12 |
# File 'app/commands/decidim/admin/officialize_user.rb', line 10 def initialize(form) @form = form end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when the officialization suceeds.
-
:invalid when the form is invalid.
Returns nothing.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/admin/officialize_user.rb', line 20 def call return broadcast(:invalid) unless form.valid? officialize_user Decidim::EventsManager.publish( event: "decidim.events.users.user_officialized", event_class: Decidim::ProfileUpdatedEvent, resource: form.user, followers: form.user.followers ) broadcast(:ok, form.user) end |