Class: Decidim::Initiatives::StatusChangeNotifier

Inherits:
Object
  • Object
show all
Defined in:
decidim-initiatives/app/services/decidim/initiatives/status_change_notifier.rb

Overview

Service that reports changes in initiative status

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ StatusChangeNotifier

Returns a new instance of StatusChangeNotifier.


9
10
11
# File 'decidim-initiatives/app/services/decidim/initiatives/status_change_notifier.rb', line 9

def initialize(args = {})
  @initiative = args.fetch(:initiative)
end

Instance Attribute Details

#initiativeObject (readonly)

Returns the value of attribute initiative


7
8
9
# File 'decidim-initiatives/app/services/decidim/initiatives/status_change_notifier.rb', line 7

def initiative
  @initiative
end

Instance Method Details

#notifyObject

PUBLIC Notifies when an initiative has changed its status.

  • created: Notifies the author that his initiative has been created.

  • validating: Administrators will be notified about the initiative that requests technical validation.

  • published, discarded: Initiative authors will be notified about the result of the technical validation process.

  • rejected, accepted: Initiative's followers and authors will be notified about the result of the initiative.


26
27
28
29
30
31
# File 'decidim-initiatives/app/services/decidim/initiatives/status_change_notifier.rb', line 26

def notify
  notify_initiative_creation if initiative.created?
  notify_validating_initiative if initiative.validating?
  notify_validating_result if initiative.published? || initiative.discarded?
  notify_support_result if initiative.rejected? || initiative.accepted?
end