Class: DispatchRider::QueueServices::FileSystem
- Inherits:
-
Base
- Object
- Base
- DispatchRider::QueueServices::FileSystem
show all
- Defined in:
- lib/dispatch-rider/queue_services/file_system.rb,
lib/dispatch-rider/queue_services/file_system/queue.rb,
lib/dispatch-rider/queue_services/file_system/fs_received_message.rb
Defined Under Namespace
Classes: FsReceivedMessage, Queue
Instance Attribute Summary
Attributes inherited from Base
#queue
Instance Method Summary
collapse
Methods inherited from Base
#empty?, #head, #initialize, #pop, #push
Instance Method Details
#assign_storage(attrs) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 10
def assign_storage(attrs)
begin
path = attrs.fetch(:path)
Queue.new(path)
rescue IndexError
raise RecordInvalid.new(self, ["Path can not be blank"])
end
end
|
#construct_message_from(item) ⇒ Object
31
32
33
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 31
def construct_message_from(item)
deserialize(item.read)
end
|
#delete(item) ⇒ Object
39
40
41
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 39
def delete(item)
queue.remove item
end
|
#insert(item) ⇒ Object
19
20
21
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 19
def insert(item)
queue.add item
end
|
#put_back(item) ⇒ Object
35
36
37
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 35
def put_back(item)
queue.put_back(item)
end
|
#raw_head ⇒ Object
23
24
25
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 23
def raw_head
queue.pop
end
|
#received_message_for(raw_item) ⇒ Object
27
28
29
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 27
def received_message_for(raw_item)
FsReceivedMessage.new(construct_message_from(raw_item), raw_item, queue)
end
|
#size ⇒ Object
43
44
45
|
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 43
def size
queue.size
end
|