Module: Notificon::Controller
- Defined in:
- lib/notificon/controller.rb
Instance Method Summary collapse
-
#_notificon_read_at ⇒ Object
Private : lazy assignment of read_at time.
-
#_track_explicit_read ⇒ Object
Private : uses notificon explicit parameters to track reads for items.
-
#_track_implicit_read ⇒ Object
Private : uses controller methods to track implicit reads for items.
-
#notificon_tracker ⇒ Object
Public : method to use as a before filter on the application controller to track read status of notifications.
Instance Method Details
#_notificon_read_at ⇒ Object
Private : lazy assignment of read_at time
40 41 42 |
# File 'lib/notificon/controller.rb', line 40 def _notificon_read_at @_notificon_read_at ||= ((respond_to?(:current_time) && current_time) || Time.now) end |
#_track_explicit_read ⇒ Object
Private : uses notificon explicit parameters to track reads for items
21 22 23 24 25 26 27 28 29 |
# File 'lib/notificon/controller.rb', line 21 def _track_explicit_read if params[Notificon.notification_item_id_param] && params[Notificon.notification_username_param] Notificon.mark_all_read_for_item(params[Notificon.notification_username_param], params[Notificon.notification_item_id_param], _notificon_read_at) true elsif id = params[Notificon.notification_id_param] Notificon.mark_notification_read(id, _notificon_read_at) true end end |
#_track_implicit_read ⇒ Object
Private : uses controller methods to track implicit reads for items
32 33 34 35 36 37 |
# File 'lib/notificon/controller.rb', line 32 def _track_implicit_read if respond_to?(:current_username) && respond_to?(:current_item_id) && current_username && current_item_id Notificon.mark_all_read_for_item(current_username, current_item_id, _notificon_read_at) true end end |
#notificon_tracker ⇒ Object
Public : method to use as a before filter on the application controller to track read status of notifications
Returns bookean indicating whether updates made
14 15 16 17 18 |
# File 'lib/notificon/controller.rb', line 14 def notificon_tracker request.get? && (_track_explicit_read | _track_implicit_read) rescue => e Notificon.logger.error { "Notificon::Controller#notificon_tracker error processing notification params - #{params.inspect} error - #{e.inspect}" } end |