Class: PlanMyStuff::Reminders::Fire
- Inherits:
-
Object
- Object
- PlanMyStuff::Reminders::Fire
- Defined in:
- lib/plan_my_stuff/reminders/fire.rb
Overview
Emits plan_my_stuff.issue.reminder_due for a single waiting issue and advances its next_reminder_at to the next milestone in the effective reminder_days schedule (or nil when the last milestone has passed).
Class Method Summary collapse
-
.ready?(issue, now: Time.now.utc) ⇒ Boolean
Returns
truewhen the issue has anext_reminder_atin the past relative tonow.
Instance Method Summary collapse
-
#call ⇒ void
Emits the reminder event and advances the schedule.
-
#initialize(issue, now: Time.now.utc) ⇒ Fire
constructor
A new instance of Fire.
Constructor Details
#initialize(issue, now: Time.now.utc) ⇒ Fire
Returns a new instance of Fire.
26 27 28 29 |
# File 'lib/plan_my_stuff/reminders/fire.rb', line 26 def initialize(issue, now: Time.now.utc) @issue = issue @now = now.utc end |
Class Method Details
.ready?(issue, now: Time.now.utc) ⇒ Boolean
Returns true when the issue has a next_reminder_at in the past relative to now.
18 19 20 21 |
# File 'lib/plan_my_stuff/reminders/fire.rb', line 18 def self.ready?(issue, now: Time.now.utc) due = issue..next_reminder_at due.present? && due <= now end |
Instance Method Details
#call ⇒ void
This method returns an undefined value.
Emits the reminder event and advances the schedule.
35 36 37 38 39 40 41 42 43 |
# File 'lib/plan_my_stuff/reminders/fire.rb', line 35 def call payload = build_payload PlanMyStuff::Notifications.instrument('issue.reminder_due', @issue, **payload) @issue.update!( metadata: { next_reminder_at: next_reminder_at_value }, skip_notification: true, ) end |