Class: Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Message
- Defined in:
- lib/generators/private_mail/install/models/message.rb
Class Method Summary collapse
-
.on_deliver(method) ⇒ Object
sets the on_deliver_callback to the passed method.
Instance Method Summary collapse
-
#deliver(mailbox_type, clean = true) ⇒ Object
delivers a message to the the given mailbox of all recipients, calls the on_deliver_callback if initialized.
Class Method Details
.on_deliver(method) ⇒ Object
sets the on_deliver_callback to the passed method. The method call should expect 2 params (message, mailbox_type).
28 29 30 |
# File 'lib/generators/private_mail/install/models/message.rb', line 28 def Message.on_deliver(method) self.on_deliver_callback = method end |
Instance Method Details
#deliver(mailbox_type, clean = true) ⇒ Object
delivers a message to the the given mailbox of all recipients, calls the on_deliver_callback if initialized.
params:
- mailbox_type
-
the mailbox to send the message to
- clean
-
calls the clean method if this is set (must be implemented)
18 19 20 21 22 23 24 25 |
# File 'lib/generators/private_mail/install/models/message.rb', line 18 def deliver(mailbox_type, clean = true) clean() if clean self.save() self.recipients.each do |r| r.mailbox[mailbox_type] << self end self.on_deliver_callback.call(self, mailbox_type) unless self.on_deliver_callback.nil? end |