Class: Decidim::ParticipatoryDocuments::Admin::NotifySuggestionAnswer
- Inherits:
-
Command
- Object
- Command
- Decidim::ParticipatoryDocuments::Admin::NotifySuggestionAnswer
- Defined in:
- app/commands/decidim/participatory_documents/admin/notify_suggestion_answer.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(suggestion, initial_state) ⇒ NotifySuggestionAnswer
constructor
Public: Initializes the command.
Constructor Details
#initialize(suggestion, initial_state) ⇒ NotifySuggestionAnswer
Public: Initializes the command.
suggestion - The suggestion to write the answer for. initial_state - The suggestion state before the current process.
11 12 13 14 |
# File 'app/commands/decidim/participatory_documents/admin/notify_suggestion_answer.rb', line 11 def initialize(suggestion, initial_state) @suggestion = suggestion @initial_state = initial_state.to_s end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:noop when the answer is not published or the state didn’t changed.
-
:ok when everything is valid.
Returns nothing.
22 23 24 25 26 27 28 |
# File 'app/commands/decidim/participatory_documents/admin/notify_suggestion_answer.rb', line 22 def call broadcast(:invalid) unless suggestion.has_answer? && suggestion.answered? && suggestion.answer_is_published? notify_followers broadcast(:ok) end |