Class: Bunny::VersionedDeliveryTag
- Inherits:
-
Object
- Object
- Bunny::VersionedDeliveryTag
- Defined in:
- lib/bunny/versioned_delivery_tag.rb
Overview
Wraps a delivery tag (which is an integer) so that Channel could detect stale tags after connection recovery.
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(tag, version) ⇒ VersionedDeliveryTag
constructor
A new instance of VersionedDeliveryTag.
- #stale?(version) ⇒ Boolean
- #to_i ⇒ Object
Constructor Details
#initialize(tag, version) ⇒ VersionedDeliveryTag
Returns a new instance of VersionedDeliveryTag.
10 11 12 13 14 15 16 |
# File 'lib/bunny/versioned_delivery_tag.rb', line 10 def initialize(tag, version) raise ArgumentError.new("tag cannot be nil") unless tag raise ArgumentError.new("version cannot be nil") unless version @tag = tag.to_i @version = version.to_i end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
7 8 9 |
# File 'lib/bunny/versioned_delivery_tag.rb', line 7 def tag @tag end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/bunny/versioned_delivery_tag.rb', line 8 def version @version end |
Instance Method Details
#stale?(version) ⇒ Boolean
22 23 24 25 26 |
# File 'lib/bunny/versioned_delivery_tag.rb', line 22 def stale?(version) raise ArgumentError.new("version cannot be nil") unless version @version < version.to_i end |
#to_i ⇒ Object
18 19 20 |
# File 'lib/bunny/versioned_delivery_tag.rb', line 18 def to_i @tag end |