Sha256: 2160ef79fcb1e8617d29e885f823844277a9e06f024f67dc5b7b88f26888e48d
Contents?: true
Size: 591 Bytes
Versions: 3
Compression:
Stored size: 591 Bytes
Contents
module Caerbannog class MessagePoller def initialize(message_class, wait_time: 5, iterations: Float::INFINITY) @message_class = message_class @wait_time = wait_time @iterations = iterations end def each &block (1..iterations).each do new_messages = fetch_new_messages if new_messages.empty? sleep wait_time else new_messages.each(&block) end end end private attr_reader :wait_time, :iterations, :message_class def fetch_new_messages message_class.all end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
caerbannog-0.2.1 | lib/caerbannog/message_poller.rb |
caerbannog-0.2.0 | lib/caerbannog/message_poller.rb |
caerbannog-0.1.0 | lib/caerbannog/message_poller.rb |