Class: Cottontail::Consumer::Collection
- Inherits:
-
Object
- Object
- Cottontail::Consumer::Collection
- Defined in:
- lib/cottontail/consumer/collection.rb
Overview
Holds the collection of entities
Instance Method Summary collapse
-
#find(delivery_info, _properties = nil, _payload = nil) ⇒ Object
‘exchange’, queue: ‘queue’, route: ‘route’ ‘exchange’, queue: ‘queue’, route: :any ‘exchange’, queue: :any, route: ‘route’ ‘exchange’, queue: :any, route: :any :any, queue: ‘queue’ :any, queue: :any.
-
#initialize ⇒ Collection
constructor
A new instance of Collection.
-
#push(entity) ⇒ Object
Pushes entity to the list and sorts it.
Constructor Details
#initialize ⇒ Collection
Returns a new instance of Collection.
5 6 7 |
# File 'lib/cottontail/consumer/collection.rb', line 5 def initialize @items = [] end |
Instance Method Details
#find(delivery_info, _properties = nil, _payload = nil) ⇒ Object
‘exchange’, queue: ‘queue’, route: ‘route’ ‘exchange’, queue: ‘queue’, route: :any ‘exchange’, queue: :any, route: ‘route’ ‘exchange’, queue: :any, route: :any :any, queue: ‘queue’ :any, queue: :any
20 21 22 23 24 25 |
# 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) ⇒ Object
Pushes entity to the list and sorts it
10 11 12 |
# File 'lib/cottontail/consumer/collection.rb', line 10 def push(entity) @items.push(entity).sort! end |