Class: Twirl::Item
- Inherits:
-
Object
- Object
- Twirl::Item
- Defined in:
- lib/twirl/item.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Private: The client that popped the item.
-
#key ⇒ Object
readonly
Public: The key of the item.
-
#value ⇒ Object
readonly
Public: The value of the item.
Instance Method Summary collapse
-
#abort ⇒ Object
Public: Something went wrong processing.
-
#close ⇒ Object
Public: Acknowledge that we are done processing the item.
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(key, value, client, instrumenter = nil) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(key, value, client, instrumenter = nil) ⇒ Item
Returns a new instance of Item.
14 15 16 17 18 19 |
# File 'lib/twirl/item.rb', line 14 def initialize(key, value, client, instrumenter = nil) @key = key @value = value @client = client @instrumenter = instrumenter || Instrumenters::Noop end |
Instance Attribute Details
#client ⇒ Object (readonly)
Private: The client that popped the item.
12 13 14 |
# File 'lib/twirl/item.rb', line 12 def client @client end |
#key ⇒ Object (readonly)
Public: The key of the item.
6 7 8 |
# File 'lib/twirl/item.rb', line 6 def key @key end |
#value ⇒ Object (readonly)
Public: The value of the item.
9 10 11 |
# File 'lib/twirl/item.rb', line 9 def value @value end |
Instance Method Details
#abort ⇒ Object
Public: Something went wrong processing.
32 33 34 35 36 37 38 39 |
# File 'lib/twirl/item.rb', line 32 def abort @instrumenter.instrument "op.twirl" do |payload| payload[:op] = :item_abort payload[:queue_name] = @key @client.abort @key end end |
#close ⇒ Object
Public: Acknowledge that we are done processing the item.
22 23 24 25 26 27 28 29 |
# File 'lib/twirl/item.rb', line 22 def close @instrumenter.instrument "op.twirl" do |payload| payload[:op] = :item_close payload[:queue_name] = @key @client.close @key end end |
#eql?(other) ⇒ Boolean Also known as: ==
41 42 43 44 45 46 |
# File 'lib/twirl/item.rb', line 41 def eql?(other) self.class.eql?(other.class) && @key == other.key && @value == other.value && @client == other.client end |