Class: Bunny::VersionedDeliveryTag

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(tag, version) ⇒ VersionedDeliveryTag

Returns a new instance of VersionedDeliveryTag.

Raises:

  • (ArgumentError)


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

#tagObject (readonly)

Returns the value of attribute tag.



7
8
9
# File 'lib/bunny/versioned_delivery_tag.rb', line 7

def tag
  @tag
end

#versionObject (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

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


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_iObject



18
19
20
# File 'lib/bunny/versioned_delivery_tag.rb', line 18

def to_i
  @tag
end