lib/fake_sqs/message.rb in fake_sqs-0.0.11 vs lib/fake_sqs/message.rb in fake_sqs-0.1.0
- old
+ new
@@ -2,14 +2,27 @@
module FakeSQS
class Message
attr_reader :body, :id, :md5
+ attr_accessor :visibility_timeout
def initialize(options = {})
@body = options.fetch("MessageBody")
@id = options.fetch("Id") { SecureRandom.uuid }
@md5 = options.fetch("MD5") { Digest::MD5.hexdigest(@body) }
+ end
+
+ def expire!
+ self.visibility_timeout = nil
+ end
+
+ def expired?( limit = Time.now )
+ self.visibility_timeout.nil? || self.visibility_timeout < limit
+ end
+
+ def expire_at(seconds)
+ self.visibility_timeout = Time.now + seconds
end
def attributes
{
"MessageBody" => body,