Class: Decidim::Messaging::StartConversation
- Defined in:
- app/commands/decidim/messaging/start_conversation.rb
Overview
A command with all the business logic for replying to a conversation
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form) ⇒ StartConversation
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction
Constructor Details
#initialize(form) ⇒ StartConversation
Public: Initializes the command.
form - A conversation form
10 11 12 |
# File 'app/commands/decidim/messaging/start_conversation.rb', line 10 def initialize(form) @form = form end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid, together with the message.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/commands/decidim/messaging/start_conversation.rb', line 20 def call return broadcast(:invalid, form.errors.) if form.invalid? if conversation.save notify_interlocutors notify_comanagers if originator.is_a?(UserGroup) broadcast(:ok, conversation) else broadcast(:invalid, conversation.errors.) end end |