Class: Storytime::PostNotifier
- Inherits:
-
Object
- Object
- Storytime::PostNotifier
- Defined in:
- lib/storytime/post_notifier.rb
Class Method Summary collapse
Class Method Details
.send_notifications_for(post_id) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/storytime/post_notifier.rb', line 3 def self.send_notifications_for(post_id) post = Storytime::Post.find_by(id: post_id) return if post.nil? unless post.notifications_sent_at post.update(notifications_sent_at: Time.now) post.site.active_email_subscriptions.each do |subscription| mail = Storytime::SubscriptionMailer.new_post_email(post, subscription) Rails::VERSION::MINOR < 2 ? mail.deliver : mail.deliver_now end end end |