Class: Alerter::Receipt
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Alerter::Receipt
- Defined in:
- app/models/alerter/receipt.rb
Class Method Summary collapse
-
.mark_as_deleted(options = {}) ⇒ Object
Marks the receipt as deleted.
-
.mark_as_not_deleted(options = {}) ⇒ Object
Marks the receipt as not deleted.
-
.mark_as_read(options = {}) ⇒ Object
Marks all the receipts from the relation as read.
-
.mark_as_unread(options = {}) ⇒ Object
Marks all the receipts from the relation as unread.
- .update_receipts(updates, options = {}) ⇒ Object
Instance Method Summary collapse
-
#is_unread? ⇒ Boolean
Returns if the participant has read the Notification.
-
#mark_as_deleted ⇒ Object
Marks the receipt as deleted.
-
#mark_as_not_deleted ⇒ Object
Marks the receipt as not deleted.
-
#mark_as_read ⇒ Object
Marks the receipt as read.
-
#mark_as_unread ⇒ Object
Marks the receipt as unread.
Class Method Details
.mark_as_deleted(options = {}) ⇒ Object
Marks the receipt as deleted
43 44 45 |
# File 'app/models/alerter/receipt.rb', line 43 def mark_as_deleted(={}) update_receipts({:deleted => true}, ) end |
.mark_as_not_deleted(options = {}) ⇒ Object
Marks the receipt as not deleted
48 49 50 |
# File 'app/models/alerter/receipt.rb', line 48 def mark_as_not_deleted(={}) update_receipts({:deleted => false}, ) end |
.mark_as_read(options = {}) ⇒ Object
Marks all the receipts from the relation as read
33 34 35 |
# File 'app/models/alerter/receipt.rb', line 33 def mark_as_read(={}) update_receipts({:is_read => true}, ) end |
.mark_as_unread(options = {}) ⇒ Object
Marks all the receipts from the relation as unread
38 39 40 |
# File 'app/models/alerter/receipt.rb', line 38 def mark_as_unread(={}) update_receipts({:is_read => false}, ) end |
.update_receipts(updates, options = {}) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/models/alerter/receipt.rb', line 53 def update_receipts(updates, ={}) ids = where().map { |rcp| rcp.id } unless ids.empty? sql = ids.map { "#{table_name}.id = ? " }.join(' OR ') conditions = [sql].concat(ids) Alerter::Receipt.where(conditions).update_all(updates) end end |
Instance Method Details
#is_unread? ⇒ Boolean
Returns if the participant has read the Notification
85 86 87 |
# File 'app/models/alerter/receipt.rb', line 85 def is_unread? !is_read end |
#mark_as_deleted ⇒ Object
Marks the receipt as deleted
65 66 67 |
# File 'app/models/alerter/receipt.rb', line 65 def mark_as_deleted update_attributes(:deleted => true) end |
#mark_as_not_deleted ⇒ Object
Marks the receipt as not deleted
70 71 72 |
# File 'app/models/alerter/receipt.rb', line 70 def mark_as_not_deleted update_attributes(:deleted => false) end |
#mark_as_read ⇒ Object
Marks the receipt as read
75 76 77 |
# File 'app/models/alerter/receipt.rb', line 75 def mark_as_read update_attributes(:is_read => true) end |
#mark_as_unread ⇒ Object
Marks the receipt as unread
80 81 82 |
# File 'app/models/alerter/receipt.rb', line 80 def mark_as_unread update_attributes(:is_read => false) end |