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

payrollhero / dispatch-rider / #3015

02 Sep 2022 11:22PM UTC coverage: 0.409% (-84.7%) from 85.154%
#3015

push

web-flow
Layout/SpaceInsideStringInterpolation-20220901233630 (#89)

* :police_car: regenerate rubocop todo

* :police_car: Layout/SpaceInsideStringInterpolation

* :police_car: regenerate rubocop todo

Co-authored-by: Rubocop Challenger <rubocop@payrollhero.com>

0 of 1 new or added line in 1 file covered. (0.0%)

1529 existing lines in 63 files now uncovered.

7 of 1711 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?
UNCOV
6
module DispatchRider
×
UNCOV
7
  module QueueServices
×
UNCOV
8
    require "dispatch-rider/queue_services/received_message"
×
UNCOV
9
    class Base
×
UNCOV
10
      attr_accessor :queue
×
11

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

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

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

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

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

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

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

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

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

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

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

UNCOV
69
      protected
×
70

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

UNCOV
75
      def deserialize(item)
×
UNCOV
76
        attrs = JSON.parse(item).symbolize_keys
×
UNCOV
77
        DispatchRider::Message.new(attrs)
×
UNCOV
78
      end
×
UNCOV
79
    end
×
UNCOV
80
  end
×
UNCOV
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

© 2025 Coveralls, Inc