Class: Decidim::Budgets::Admin::CreateOrderReminders

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/budgets/admin/create_order_reminders.rb

Overview

This command is executed when an admin sends vote reminders.

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateOrderReminders

Returns a new instance of CreateOrderReminders.



10
11
12
# File 'app/commands/decidim/budgets/admin/create_order_reminders.rb', line 10

def initialize(form)
  @form = form
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
# File 'app/commands/decidim/budgets/admin/create_order_reminders.rb', line 14

def call
  return broadcast(:invalid) if form.invalid?
  return broadcast(:invalid) unless voting_enabled?
  return broadcast(:invalid) if voting_ends_soon?

  generator.generate_for(current_component, &alternative_refresh_state)

  broadcast(:ok, generator.reminder_jobs_queued)
end