• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

payrollhero / dispatch-rider / #3012

17 Aug 2022 10:39PM UTC coverage: 0.409% (-84.7%) from 85.141%
#3012

push

web-flow
Merge pull request #80 from payrollhero/support-aws-sdk-1-2-3

Support aws-sdk v1 and v3 - Fix for Security Update Rails (CVE-2022-32224)

7 of 1712 relevant lines covered (0.41%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/dispatch-rider/queue_services/base.rb
1
# This is the base class that provides the template for all queue services.
2
# The child classes must implement the following methods to become a concrete class :
3
# assign_storage, insert, raw_head, construct_message_from, delete and size.
4
# The instances of this class or it's child classes are supposed to perform the following actions on the queue service :
5
# initialize, push, pop and empty?
6
module DispatchRider
×
7
  module QueueServices
×
8
    require "dispatch-rider/queue_services/received_message"
×
9
    class Base
×
10
      attr_accessor :queue
×
11

12
      def initialize(options = {})
×
13
        @queue = assign_storage(options.symbolize_keys)
×
14
      end
×
15

16
      def assign_storage(attrs)
×
17
        raise NotImplementedError
×
18
      end
×
19

20
      def push(item)
×
21
        message = serialize(item)
×
22
        insert(message)
×
23
        message
×
24
      end
×
25

26
      def insert(item)
×
27
        raise NotImplementedError
×
28
      end
×
29

30
      
31
      #If you pass a block into pop it will wrap the deletion of the message with it's handling
32
      def pop(&block)
×
33
        received = head
×
34
        if received
×
35
          block.call(received) && delete(received.item)
×
36
          received
×
37
        end
×
38
      end
×
39

40
      def head
×
41
        raw_item = raw_head
×
42
        raw_item && received_message_for(raw_item)
×
43
      end
×
44
      
45
      def received_message_for(raw_item)
×
46
         QueueServices::ReceivedMessage.new(construct_message_from(raw_item), raw_item)
×
47
      end
×
48

49
      def raw_head
×
50
        raise NotImplementedError
×
51
      end
×
52

53
      def construct_message_from(item)
×
54
        raise NotImplementedError
×
55
      end
×
56

57
      def delete(item)
×
58
        raise NotImplementedError
×
59
      end
×
60

61
      def empty?
×
62
        size.zero?
×
63
      end
×
64

65
      def size
×
66
        raise NotImplementedError
×
67
      end
×
68

69
      protected
×
70

71
      def serialize(item)
×
72
        item.to_json
×
73
      end
×
74

75
      def deserialize(item)
×
76
        attrs = JSON.parse(item).symbolize_keys
×
77
        DispatchRider::Message.new(attrs)
×
78
      end
×
79
    end
×
80
  end
×
81
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc