module Notably::Notifiable
Public Instance Methods
last_notification_read_at()
click to toggle source
# File lib/notably/notifiable.rb, line 28 def last_notification_read_at Notably.config.redis.get(last_notification_read_at_key).to_i end
last_notification_read_at_key()
click to toggle source
# File lib/notably/notifiable.rb, line 36 def last_notification_read_at_key "notably:last_read_at:#{self.class}:#{self.id}" end
notification_key()
click to toggle source
# File lib/notably/notifiable.rb, line 32 def notification_key "notably:notifications:#{self.class}:#{self.id}" end
notifications()
click to toggle source
# File lib/notably/notifiable.rb, line 4 def notifications parse_notifications(Notably.config.redis.zrevrangebyscore(notification_key, Time.now.to_i, 0)) end
notifications_since(time)
click to toggle source
# File lib/notably/notifiable.rb, line 8 def notifications_since(time) parse_notifications(Notably.config.redis.zrevrangebyscore(notification_key, Time.now.to_i, time.to_i)) end
read_notifications()
click to toggle source
# File lib/notably/notifiable.rb, line 20 def read_notifications parse_notifications(Notably.config.redis.zrevrangebyscore(notification_key, last_notification_read_at, 0)) end
read_notifications!()
click to toggle source
# File lib/notably/notifiable.rb, line 24 def read_notifications! parse_notifications(Notably.config.redis.set(last_notification_read_at_key, Time.now.to_i)) end
unread_notifications()
click to toggle source
# File lib/notably/notifiable.rb, line 12 def unread_notifications notifications_since(last_notification_read_at) end
unread_notifications!()
click to toggle source
# File lib/notably/notifiable.rb, line 16 def unread_notifications! notifications_since(Notably.config.redis.getset(last_notification_read_at_key, Time.now.to_i)) end
Private Instance Methods
parse_notifications(notifications)
click to toggle source
# File lib/notably/notifiable.rb, line 42 def parse_notifications(notifications) notifications.collect { |n| Marshal.load(n) } end