Class: FakeSQS::Message
- Inherits:
-
Object
- Object
- FakeSQS::Message
- Defined in:
- lib/fake_sqs/message.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#md5 ⇒ Object
readonly
Returns the value of attribute md5.
-
#visibility_timeout ⇒ Object
Returns the value of attribute visibility_timeout.
Instance Method Summary collapse
- #attributes ⇒ Object
- #expire! ⇒ Object
- #expire_at(seconds) ⇒ Object
- #expired?(limit = Time.now) ⇒ Boolean
-
#initialize(options = {}) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(options = {}) ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 |
# File 'lib/fake_sqs/message.rb', line 9 def initialize( = {}) @body = .fetch("MessageBody") @id = .fetch("Id") { SecureRandom.uuid } @md5 = .fetch("MD5") { Digest::MD5.hexdigest(@body) } end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/fake_sqs/message.rb', line 6 def body @body end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/fake_sqs/message.rb', line 6 def id @id end |
#md5 ⇒ Object (readonly)
Returns the value of attribute md5.
6 7 8 |
# File 'lib/fake_sqs/message.rb', line 6 def md5 @md5 end |
#visibility_timeout ⇒ Object
Returns the value of attribute visibility_timeout.
7 8 9 |
# File 'lib/fake_sqs/message.rb', line 7 def visibility_timeout @visibility_timeout end |
Instance Method Details
#attributes ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/fake_sqs/message.rb', line 27 def attributes { "MessageBody" => body, "Id" => id, "MD5" => md5, } end |
#expire! ⇒ Object
15 16 17 |
# File 'lib/fake_sqs/message.rb', line 15 def expire! self.visibility_timeout = nil end |
#expire_at(seconds) ⇒ Object
23 24 25 |
# File 'lib/fake_sqs/message.rb', line 23 def expire_at(seconds) self.visibility_timeout = Time.now + seconds end |
#expired?(limit = Time.now) ⇒ Boolean
19 20 21 |
# File 'lib/fake_sqs/message.rb', line 19 def expired?( limit = Time.now ) self.visibility_timeout.nil? || self.visibility_timeout < limit end |