Class: Alerter::Mailbox
- Inherits:
-
Object
- Object
- Alerter::Mailbox
- Defined in:
- app/models/alerter/mailbox.rb
Instance Attribute Summary collapse
-
#notifiable ⇒ Object
readonly
Returns the value of attribute notifiable.
Instance Method Summary collapse
-
#all_messages(options = {}) ⇒ Object
Returns the messages for the messageable.
-
#inbox(options = {}) ⇒ Object
Returns the messages in the inbox of notifiable.
-
#initialize(notifiable) ⇒ Mailbox
constructor
Initializer method.
-
#messages(options = {}) ⇒ Object
Returns the conversations for the messageable.
-
#receipts(options = {}) ⇒ Object
Returns all the receipts of notifiable from Messages.
- #trash(options = {}) ⇒ Object
Constructor Details
#initialize(notifiable) ⇒ Mailbox
Initializer method
5 6 7 |
# File 'app/models/alerter/mailbox.rb', line 5 def initialize(notifiable) @notifiable = notifiable end |
Instance Attribute Details
#notifiable ⇒ Object (readonly)
Returns the value of attribute notifiable.
2 3 4 |
# File 'app/models/alerter/mailbox.rb', line 2 def notifiable @notifiable end |
Instance Method Details
#all_messages(options = {}) ⇒ Object
Returns the messages for the messageable
10 11 12 13 14 15 16 17 18 |
# File 'app/models/alerter/mailbox.rb', line 10 def ( = {}) #:type => nil is a hack not to give Messages as Notifications = Alerter::Message.receipts(@notifiable).where(:type => nil).order("alerter_messages.created_at DESC") if [:read] == false || [:unread] = .unread end end |
#inbox(options = {}) ⇒ Object
Returns the messages in the inbox of notifiable
Same as conversations(=> ‘inbox’)
44 45 46 47 |
# File 'app/models/alerter/mailbox.rb', line 44 def inbox(={}) = .merge(:mailbox_type => 'inbox') () end |
#messages(options = {}) ⇒ Object
Returns the conversations for the messageable
Options
-
:mailbox_type
-
“inbox”
-
“trash”
-
:read=false
-
:unread=true
31 32 33 34 35 36 37 38 39 |
# File 'app/models/alerter/mailbox.rb', line 31 def ( = {}) = ([:mailbox_type]) if [:read] == false || [:unread] = .unread #(notifiable) end end |
#receipts(options = {}) ⇒ Object
Returns all the receipts of notifiable from Messages
56 57 58 |
# File 'app/models/alerter/mailbox.rb', line 56 def receipts( = {}) Alerter::Receipt.where().recipient(notifiable) end |
#trash(options = {}) ⇒ Object
49 50 51 52 |
# File 'app/models/alerter/mailbox.rb', line 49 def trash(={}) = .merge(:mailbox_type => 'trash') () end |