Sha256: 5158f43846ab23ad0add5055abb65ceb7252c01bfaaa58c1191ad60b98ac314a
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'ancestry' module ActsAsMessageable class Message < ::ActiveRecord::Base include ActsAsMessageable::Scopes belongs_to :received_messageable, polymorphic: true belongs_to :sent_messageable, polymorphic: true attr_accessor :removed, :restored cattr_accessor :required ActsAsMessageable.rails_api.new(self).default_scope('created_at desc') def open? opened? end def open update_attributes!(opened: true) end alias mark_as_read open alias read open def close update_attributes!(opened: false) end alias mark_as_unread close alias unread close alias from sent_messageable alias to received_messageable def real_receiver(user) user == from ? to : from end def participant?(user) user.class.group_messages || (to == user) || (from == user) end def conversation root.subtree end def delete self.removed = true end def restore self.restored = true end def reply(*args) to.reply_to(self, *args) end def people conversation.map(&:from).uniq! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts-as-messageable-0.4.11 | lib/acts-as-messageable/message.rb |