module Shiroyagi::ActsAsShiroyagi
Public Instance Methods
acts_as_shiroyagi(options = {})
click to toggle source
TODO: The read_at column name should be customizable via an argument.
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 7 def acts_as_shiroyagi(options = {}) end
mark_all_as_read()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 18 def mark_all_as_read unreads.update(read_at: Time.current) end
mark_all_as_unread()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 22 def mark_all_as_unread reads.update(read_at: nil) end
mark_as_read()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 31 def mark_as_read update(read_at: Time.current) if unread? end
mark_as_read!()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 39 def mark_as_read! update!(read_at: Time.current) if unread? end
mark_as_unread()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 35 def mark_as_unread update(read_at: nil) if read? end
mark_as_unread!()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 43 def mark_as_unread! update!(read_at: nil) if read? end
read?()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 47 def read? read_at.present? end
reads_count()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 10 def reads_count reads.count end
unread?()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 51 def unread? read_at.blank? end
unreads_count()
click to toggle source
# File lib/shiroyagi/acts_as_shiroyagi.rb, line 14 def unreads_count unreads.count end