Class: Communicator::OutboundMessage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Communicator::OutboundMessage
- Defined in:
- lib/communicator/outbound_message.rb
Class Method Summary collapse
-
.delivery_collection(from_id = nil) ⇒ Object
Returns an array of all undelivered messages.
Instance Method Summary collapse
-
#delivered! ⇒ Object
Set the delivered_at flag to NOW and save!.
-
#message_content ⇒ Object
Will return the JSON-parsed content of this message’s body.
-
#payload ⇒ Object
Stripped down content hash for json delivery.
Class Method Details
.delivery_collection(from_id = nil) ⇒ Object
Returns an array of all undelivered messages. If the optional id is given will instead start from that id, not taking care whether the messages have already been marked as delivered.
11 12 13 |
# File 'lib/communicator/outbound_message.rb', line 11 def self.delivery_collection(from_id=nil) (from_id ? all(:conditions => ["id >= ?", from_id]) : undelivered) end |
Instance Method Details
#delivered! ⇒ Object
Set the delivered_at flag to NOW and save!
26 27 28 29 |
# File 'lib/communicator/outbound_message.rb', line 26 def delivered! self.delivered_at = Time.now self.save! end |
#message_content ⇒ Object
Will return the JSON-parsed content of this message’s body
21 22 23 |
# File 'lib/communicator/outbound_message.rb', line 21 def JSON.parse(body).with_indifferent_access end |
#payload ⇒ Object
Stripped down content hash for json delivery
16 17 18 |
# File 'lib/communicator/outbound_message.rb', line 16 def payload {:id => id, :body => body} end |