class Cottontail::Consumer::Collection

Holds the collection of entities

Public Class Methods

new() click to toggle source
# File lib/cottontail/consumer/collection.rb, line 5
def initialize
  @items = []
end

Public Instance Methods

find(delivery_info, _properties = nil, _payload = nil) click to toggle source

{exchange: ‘exchange’, queue: ‘queue’, route: ‘route’} {exchange: ‘exchange’, queue: ‘queue’, route: :any} {exchange: ‘exchange’, queue: :any, route: ‘route’} {exchange: ‘exchange’, queue: :any, route: :any} {exchange: :any, queue: ‘queue’} {exchange: :any, queue: :any}

# File lib/cottontail/consumer/collection.rb, line 20
def find(delivery_info, _properties = nil, _payload = nil)
  @items
    .select { |e| e.matches?(:exchange, delivery_info.exchange) }
    .select { |e| e.matches?(:queue, delivery_info.consumer.queue.name) }
    .find { |e| e.matches?(:route, delivery_info.routing_key) }
end
push(entity) click to toggle source

Pushes entity to the list and sorts it

# File lib/cottontail/consumer/collection.rb, line 10
def push(entity)
  @items.push(entity).sort!
end