Class: Decidim::Initiatives::ProgressNotifier

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

Overview

Service that notifies progress for an initiative

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ProgressNotifier

Returns a new instance of ProgressNotifier.



9
10
11
# File 'decidim-initiatives/app/services/decidim/initiatives/progress_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/progress_notifier.rb', line 7

def initiative
  @initiative
end

Instance Method Details

#notifyObject

PUBLIC: Notifies the support progress of the initiative.

Notifies to Initiative’s authors and followers about the number of supports received by the initiative.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'decidim-initiatives/app/services/decidim/initiatives/progress_notifier.rb', line 17

def notify
  initiative.followers.each do |follower|
    Decidim::Initiatives::InitiativesMailer
      .notify_progress(initiative, follower)
      .deliver_later
  end

  initiative.committee_members.approved.each do |committee_member|
    Decidim::Initiatives::InitiativesMailer
      .notify_progress(initiative, committee_member.user)
      .deliver_later
  end

  Decidim::Initiatives::InitiativesMailer
    .notify_progress(initiative, initiative.author)
    .deliver_later
end