lib/dispatch-rider/queue_services/base.rb in dispatch-rider-2.1.0 vs lib/dispatch-rider/queue_services/base.rb in dispatch-rider-2.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
# This is the base class that provides the template for all queue services.
# The child classes must implement the following methods to become a concrete class :
# assign_storage, insert, raw_head, construct_message_from, delete and size.
# The instances of this class or it's child classes are supposed to perform the following actions on the queue service :
# initialize, push, pop and empty?
@@ -25,24 +27,23 @@
def insert(item)
raise NotImplementedError
end
-
#If you pass a block into pop it will wrap the deletion of the message with it's handling
- def pop(&block)
+ def pop
received = head
if received
- block.call(received) && delete(received.item)
+ yield(received) && delete(received.item)
received
end
end
def head
raw_item = raw_head
raw_item && received_message_for(raw_item)
end
-
+
def received_message_for(raw_item)
QueueServices::ReceivedMessage.new(construct_message_from(raw_item), raw_item)
end
def raw_head