Class: Karafka::Workers::Builder
- Inherits:
-
Object
- Object
- Karafka::Workers::Builder
- Defined in:
- lib/karafka/workers/builder.rb
Overview
Builder is used to check if there is a proper controller with the same name as a controller and if not, it will create a default one using Karafka::BaseWorker This is used as a building layer between controllers and workers. it will be only used when user does not provide his own worker that should perform controller stuff
Instance Method Summary collapse
-
#build ⇒ Class
Sidekiq worker class that already exists or new build based on the provided controller_class name.
-
#initialize(controller_class) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(controller_class) ⇒ Builder
Returns a new instance of Builder.
12 13 14 |
# File 'lib/karafka/workers/builder.rb', line 12 def initialize(controller_class) @controller_class = controller_class end |
Instance Method Details
#build ⇒ Class
Returns Sidekiq worker class that already exists or new build based on the provided controller_class name.
22 23 24 25 26 |
# File 'lib/karafka/workers/builder.rb', line 22 def build return matcher.match if matcher.match klass = Class.new(base) matcher.scope.const_set(matcher.name, klass) end |