Sha256: b783744996f3745fa4f1b510f06d367f8662c34951911a86b1b534e35cd272dc
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
module Unread def self.included(base) base.extend Base end module Base def acts_as_reader ReadMark.reader_classes ||= [] unless ReadMark.reader_classes.include?(self) ReadMark.belongs_to :reader, polymorphic: true, inverse_of: :read_marks, optional: true has_many :read_marks, dependent: :delete_all, as: :reader, inverse_of: :reader after_create :setup_new_reader ReadMark.reader_classes << self include Reader::InstanceMethods extend Reader::ClassMethods extend Reader::Scopes end end def acts_as_readable(options={}) ReadMark.readable_classes ||= [] unless ReadMark.readable_classes.include?(self) class_attribute :readable_options options.reverse_merge!(on: :updated_at) self.readable_options = options has_many :read_marks, as: :readable, dependent: :delete_all, inverse_of: :readable ReadMark.readable_classes << self include Readable::InstanceMethods extend Readable::ClassMethods extend Readable::Scopes end end def using_postgresql? connection.adapter_name.match(/postgres/i) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
unread-0.14.0 | lib/unread/base.rb |
unread-0.13.1 | lib/unread/base.rb |
unread-0.13.0 | lib/unread/base.rb |
unread-0.12.0 | lib/unread/base.rb |