diff options
Diffstat (limited to 'app/services/parent_notifier.rb')
| -rw-r--r-- | app/services/parent_notifier.rb | 19 | 
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/parent_notifier.rb b/app/services/parent_notifier.rb new file mode 100644 index 000000000..653c98aff --- /dev/null +++ b/app/services/parent_notifier.rb @@ -0,0 +1,19 @@ +class ParentNotifier +  def initialize(klass) +    @klass = klass +  end + +  def notify_when_finished(collection = nil) +    collection ||= objects_pending_notification +    collection.each(&:notify_parent) +  end + +  def objects_pending_notification +    @klass +      .where( +        notified_parent_at: nil, +        status: @klass.finished_statuses +      ) +      .where.not(parent: nil) +  end +end  | 
