lib/unread_mongoid/base.rb in unread-mongoid-0.0.1 vs lib/unread_mongoid/base.rb in unread-mongoid-0.0.2

- old
+ new

@@ -26,9 +26,17 @@ self.readable_options = options has_many :read_marks, :as => :readable, :dependent => :delete_all + # :( + after_save do |doc| + doc.read_marks.each do |mark| + mark.readable_timestamp = doc.readable_timestamp + mark.save! + end + end + ReadMark.readable_classes ||= [] ReadMark.readable_classes << self unless ReadMark.readable_classes.include?(self) include Readable::InstanceMethods extend Readable::ClassMethods