Class: Karafka::Routing::Topics
- Inherits:
-
Object
- Object
- Karafka::Routing::Topics
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/karafka/routing/topics.rb
Overview
Abstraction layer on top of groups of topics
Direct Known Subclasses
Instance Method Summary collapse
-
#delete_if ⇒ Object
Allows us to remove elements from the topics.
-
#each ⇒ Object
Yields each topic.
-
#find(topic_name) ⇒ Karafka::Routing::Topic
Finds topic by its name.
-
#initialize(topics_array) ⇒ Topics
constructor
A new instance of Topics.
Constructor Details
#initialize(topics_array) ⇒ Topics
Returns a new instance of Topics.
13 14 15 |
# File 'lib/karafka/routing/topics.rb', line 13 def initialize(topics_array) @accumulator = topics_array.dup end |
Instance Method Details
#delete_if ⇒ Object
Allows us to remove elements from the topics
Block to decide what to delete
25 26 27 |
# File 'lib/karafka/routing/topics.rb', line 25 def delete_if(&) @accumulator.delete_if(&) end |
#each ⇒ Object
Yields each topic
18 19 20 |
# File 'lib/karafka/routing/topics.rb', line 18 def each(&) @accumulator.each(&) end |
#find(topic_name) ⇒ Karafka::Routing::Topic
Finds topic by its name
35 36 37 38 |
# File 'lib/karafka/routing/topics.rb', line 35 def find(topic_name) @accumulator.find { |topic| topic.name == topic_name } || raise(Karafka::Errors::TopicNotFoundError, topic_name) end |