Sha256: 0a7d6d8dd1658a9ab56caf27d1cc954420ce72e983b6f352addb5fab331efe1e

Contents?: true

Size: 430 Bytes

Versions: 26

Compression:

Stored size: 430 Bytes

Contents

module WebsocketRails
  class EventQueue

    attr_reader :queue

    def initialize
      @queue = []
    end

    def enqueue(event)
      @queue << event
    end
    alias :<< :enqueue

    def last
      @queue.last
    end

    def size
      @queue.size
    end

    def flush(&block)
      unless block.nil?
        @queue.each do |item|
          block.call item
        end
      end
      @queue = []
    end

  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
websocket-rails-0.2.1 lib/websocket_rails/event_queue.rb
websocket-rails-0.2.0 lib/websocket_rails/event_queue.rb
websocket-rails-0.1.9 lib/websocket_rails/event_queue.rb
websocket-rails-0.1.8 lib/websocket_rails/event_queue.rb
websocket-rails-0.1.7 lib/websocket_rails/event_queue.rb
websocket-rails-0.1.6 lib/websocket_rails/event_queue.rb