Sha256: 277a19c29b22f47b518ef2b646b80effd79dd9a6dd89273bb491252d55db6bc6
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module UnreadMongoid module Readable module ClassMethods def mark_as_read!(target, options) reader = options[:for] UnreadMongoid::Reader.assert_reader(reader) readables_to_mark = if(target == :all) self.unread_by(reader) else target end self.unread_by(reader).each do |readable| raise ArgumentError unless readable.is_a? self readable.mark_as_read! :for => reader end end end module InstanceMethods def unread?(reader) UnreadMongoid::Reader.assert_reader(reader) ReadMark.where(reader: reader, readable: self).empty? end def mark_as_read!(options) reader = options[:for] UnreadMongoid::Reader.assert_reader(reader) ReadMark.create(reader: reader, readable: self) end def mark_as_unread! self.read_marks.destroy_all end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unread-mongoid-0.1.0 | lib/unread_mongoid/readable.rb |