app/models/mailbox.rb in mailboxer-0.2.0 vs app/models/mailbox.rb in mailboxer-0.2.1
- old
+ new
@@ -7,11 +7,11 @@
end
#Returns the notifications for the messageable
def notifications(options = {})
#:type => nil is a hack not to give Messages as Notifications
- return Notification.receiver(@messageable).where(:type => nil)
+ return Notification.recipient(@messageable).where(:type => nil)
end
#Returns the conversations for the messageable
#
#Options
@@ -69,11 +69,11 @@
return self.conversations(options)
end
#Returns all the receipts of messageable, from Messages and Notifications
def receipts(options = {})
- return Receipt.where(options).receiver(@messageable)
+ return Receipt.where(options).recipient(@messageable)
end
#Deletes all the messages in the trash of messageable. NOT IMPLEMENTED.
def empty_trash(options = {})
#TODO
@@ -93,23 +93,25 @@
#Returns true if messageable has trashed all the messages of the conversation
def is_completely_trashed?(conversation)
return conversation.is_completely_trashed?(@messageable)
end
- #Returns the receipts of object for messageable
+ #Returns the receipts of object for messageable as a ActiveRecord::Relation
#
#Object can be:
#* A Message
#* A Notification
#* A Conversation
+ #
+ #If object isn't one of the above, a nil will be returned
def receipts_for(object)
case object
- when Message,Notification
- return [object.receipt_for(@messageable)]
+ when Message, Notification
+ return object.receipt_for(@messageable)
when Conversation
return object.receipts_for(@messageable)
else
- return Array.new
+ return nil
end
end
end