Class: BookmarkReminderNotificationHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/bookmark_reminder_notification_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bookmark) ⇒ BookmarkReminderNotificationHandler

Returns a new instance of BookmarkReminderNotificationHandler.



6
7
8
# File 'lib/bookmark_reminder_notification_handler.rb', line 6

def initialize(bookmark)
  @bookmark = bookmark
end

Instance Attribute Details

#bookmarkObject (readonly)

Returns the value of attribute bookmark.



4
5
6
# File 'lib/bookmark_reminder_notification_handler.rb', line 4

def bookmark
  @bookmark
end

Instance Method Details

#send_notificationObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bookmark_reminder_notification_handler.rb', line 10

def send_notification
  return if bookmark.blank?
  Bookmark.transaction do
    if !bookmark.registered_bookmarkable.can_send_reminder?(bookmark)
      clear_reminder
    else
      bookmark.registered_bookmarkable.send_reminder_notification(bookmark)

      if bookmark.auto_delete_when_reminder_sent?
        BookmarkManager.new(bookmark.user).destroy(bookmark.id)
      end

      clear_reminder
    end
  end
end