Class: DispatchRider::QueueServices::FileSystem

Inherits:
Base
  • Object
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, #size

Constructor Details

This class inherits a constructor from DispatchRider::QueueServices::Base

Instance Method Details

#assign_storage(attrs) ⇒ Object



12
13
14
15
16
17
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 12

def assign_storage(attrs)
    path = attrs.fetch(:path)
    Queue.new(path)
rescue IndexError
    raise RecordInvalid.new(self, ["Path can not be blank"])
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



37
38
39
# File 'lib/dispatch-rider/queue_services/file_system.rb', line 37

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

#raw_headObject



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