Class: Decidim::Messaging::ReplyToConversation
- Defined in:
- app/commands/decidim/messaging/reply_to_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(conversation, form) ⇒ ReplyToConversation
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction
Constructor Details
#initialize(conversation, form) ⇒ ReplyToConversation
Public: Initializes the command.
conversation - The conversation to be updated. form - A form object with the params.
11 12 13 14 |
# File 'app/commands/decidim/messaging/reply_to_conversation.rb', line 11 def initialize(conversation, form) @conversation = conversation @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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/commands/decidim/messaging/reply_to_conversation.rb', line 22 def call if form.invalid? .valid? return broadcast(:invalid, .errors.) end if .save notify_interlocutors notify_comanagers if sender.is_a?(UserGroup) broadcast(:ok, ) else broadcast(:invalid, .errors.) end end |