Class: BBK::AMQP::DomainsSet

Inherits:
Object
  • Object
show all
Defined in:
lib/bbk/amqp/domains_set.rb

Overview

Store for amqp domains. Domain is pair: domain name and exchange name.

Instance Method Summary collapse

Constructor Details

#initialize(*domains) ⇒ DomainsSet

Returns a new instance of DomainsSet.



8
9
10
# File 'lib/bbk/amqp/domains_set.rb', line 8

def initialize(*domains)
  @domains = domains.map{|d| [d.name.to_s, d] }.to_h
end

Instance Method Details

#[](domain_name) ⇒ String

Get exchange name by domain

Parameters:

  • domain_name (String)

    domain name

Returns:

  • (String)

    exchange name configured for passed domain name



15
16
17
# File 'lib/bbk/amqp/domains_set.rb', line 15

def [](domain_name)
  @domains[domain_name]
end

#add(domain) ⇒ Object Also known as: <<



19
20
21
# File 'lib/bbk/amqp/domains_set.rb', line 19

def add(domain)
  @domains[domain.name.to_s] = domain
end

#each(&block) ⇒ Object

Each method implementation for object iteration



26
27
28
# File 'lib/bbk/amqp/domains_set.rb', line 26

def each(&block)
  @domains.values.each(&block)
end

#has?(domain_name) ⇒ Boolean

Check if store has information about domain

Parameters:

  • domain_name (String)

    domain name

Returns:

  • (Boolean)

    has information about domain



33
34
35
# File 'lib/bbk/amqp/domains_set.rb', line 33

def has?(domain_name)
  @domains.key? domain_name
end