Class: MarchHare::VersionedDeliveryTag

Inherits:
Object
  • Object
show all
Defined in:
lib/march_hare/versioned_delivery_tag.rb

Overview

Wraps a delivery tag (which is an integer) so that Bunny::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/march_hare/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
  @version = version
end

Instance Attribute Details

#tagObject (readonly)

Returns the value of attribute tag.



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

def tag
  @tag
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/march_hare/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/march_hare/versioned_delivery_tag.rb', line 22

def stale?(version)
  raise ArgumentError.new("version cannot be nil") unless version

  @version < version
end

#to_iObject



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

def to_i
  @tag
end