Sha256: 56e895e6cccfedcda0444f2130c26ac128d04de24945dea4e606491386d7fdfa
Contents?: true
Size: 663 Bytes
Versions: 2
Compression:
Stored size: 663 Bytes
Contents
class ReadMark include Mongoid::Document field :timestamp, type: Time field :readable_timestamp, type: Time, default: -> { readable.readable_timestamp if readable } belongs_to :readable, :polymorphic => true belongs_to :user validates_presence_of :user_id, :readable_type scope :global, -> { where(:readable_id => nil) } scope :single, -> { ne(readable_id: nil) } scope :older_than, -> (timestamp) { lt(timestamp: timestamp) } # Returns the class defined by acts_as_reader def self.reader_class reflect_on_all_associations(:belongs_to).find { |assoc| assoc.name == :user }.try(:klass) end class_attribute :readable_classes end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unread-mongoid-0.0.3 | lib/unread_mongoid/read_mark.rb |
unread-mongoid-0.0.2 | lib/unread_mongoid/read_mark.rb |