Class: Receipt

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/receipt.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.mark_as_read(options = {}) ⇒ Object

Marks all the receipts from the relation as read



32
33
34
# File 'app/models/receipt.rb', line 32

def mark_as_read(options={})
	where(options).update_all(:read => true)
end

.mark_as_unread(options = {}) ⇒ Object

Marks all the receipts from the relation as unread



37
38
39
# File 'app/models/receipt.rb', line 37

def mark_as_unread(options={})
	where(options).update_all(:read => false)
end

.move_to_inbox(options = {}) ⇒ Object

Moves all the receipts from the relation to inbox



52
53
54
# File 'app/models/receipt.rb', line 52

def move_to_inbox(options={})
	where(options).update_all(:mailbox_type => :inbox, :trashed => false)
end

.move_to_sentbox(options = {}) ⇒ Object

Moves all the receipts from the relation to sentbox



57
58
59
# File 'app/models/receipt.rb', line 57

def move_to_sentbox(options={})
	where(options).update_all(:mailbox_type => :sentbox, :trashed => false)
end

.move_to_trash(options = {}) ⇒ Object

Marks all the receipts from the relation as trashed



42
43
44
# File 'app/models/receipt.rb', line 42

def move_to_trash(options={})
	where(options).update_all(:trashed => true)
end

.untrash(options = {}) ⇒ Object

Marks all the receipts from the relation as not trashed



47
48
49
# File 'app/models/receipt.rb', line 47

def untrash(options={})
	where(options).update_all(:trashed => false)
end

Instance Method Details

#conversationObject

Returns the conversation associated to the receipt if the notification is a Message



93
94
95
96
# File 'app/models/receipt.rb', line 93

def conversation
  return message.conversation if message.is_a? Message
  return nil
end

#mark_as_readObject

Marks the receipt as read



63
64
65
# File 'app/models/receipt.rb', line 63

def mark_as_read
	update_attributes(:read => true)
end

#mark_as_unreadObject

Marks the receipt as unread



68
69
70
# File 'app/models/receipt.rb', line 68

def mark_as_unread
	update_attributes(:read => false)
end

#move_to_inboxObject

Moves the receipt to inbox



83
84
85
# File 'app/models/receipt.rb', line 83

def move_to_inbox
	update_attributes(:mailbox_type => :inbox, :trashed => false)
end

#move_to_sentboxObject

Moves the receipt to sentbox



88
89
90
# File 'app/models/receipt.rb', line 88

def move_to_sentbox
	update_attributes(:mailbox_type => :sentbox, :trashed => false)
end

#move_to_trashObject

Marks the receipt as trashed



73
74
75
# File 'app/models/receipt.rb', line 73

def move_to_trash
	update_attributes(:trashed => true)
end

#untrashObject

Marks the receipt as not trashed



78
79
80
# File 'app/models/receipt.rb', line 78

def untrash
	update_attributes(:trashed => false)
end