Module: ActsAsReadable::ActMethod
- Defined in:
- lib/acts_as_readable/acts_as_readable.rb
Instance Method Summary collapse
-
#acts_as_readable(options = {}) ⇒ Object
OPTIONS :cache => the name under which to cache timestamps for a “mark all as read” action to avoid the need to actually create readings for each record marked as read.
- #acts_as_reader ⇒ Object
Instance Method Details
#acts_as_readable(options = {}) ⇒ Object
OPTIONS :cache => the name under which to cache timestamps for a “mark all as read” action to avoid the need to actually create readings for each record marked as read
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/acts_as_readable/acts_as_readable.rb', line 5 def acts_as_readable( = {}) class_attribute :acts_as_readable_options self. = has_many :readings, :as => :readable, :dependent => :delete_all has_many :readers, lambda { where :readings => {:state => 'read'} }, :through => :readings, :source => :user scope :read_by, lambda {|user| ActsAsReadable::HelperMethods.outer_join_readings(all, user).where(ActsAsReadable::HelperMethods.read_conditions(self, user, :created_at))} scope :unread_by, lambda {|user| ActsAsReadable::HelperMethods.outer_join_readings(all, user).where(ActsAsReadable::HelperMethods.unread_conditions(self, user, :created_at))} scope :latest_update_read_by, lambda {|user| ActsAsReadable::HelperMethods.outer_join_readings(all, user).where(ActsAsReadable::HelperMethods.read_conditions(self, user, :updated_at))} scope :latest_update_unread_by, lambda {|user| ActsAsReadable::HelperMethods.outer_join_readings(all, user).where(ActsAsReadable::HelperMethods.unread_conditions(self, user, :updated_at))} extend ActsAsReadable::ClassMethods include ActsAsReadable::InstanceMethods end |
#acts_as_reader ⇒ Object
21 22 23 |
# File 'lib/acts_as_readable/acts_as_readable.rb', line 21 def acts_as_reader has_many :readings, :dependent => :delete_all end |