lib/karafka/responders/builder.rb in karafka-1.1.2 vs lib/karafka/responders/builder.rb in karafka-1.2.0.beta1

- old
+ new

@@ -1,33 +1,34 @@ # frozen_string_literal: true module Karafka # Responders namespace encapsulates all the internal responder implementation parts module Responders - # Responders builder is used to find (based on the controller class name) a responder that - # match the controller. This is used when user does not provide a responder inside routing - # but he still names responder with the same convention (and namespaces) as controller + # Responders builder is used to finding (based on the consumer class name) a responder + # that match the consumer. We use it when user does not provide a responder inside routing, + # but he still names responder with the same convention (and namespaces) as consumer + # # @example Matching responder exists - # Karafka::Responder::Builder(NewEventsController).build #=> NewEventsResponder + # Karafka::Responder::Builder(NewEventsConsumer).build #=> NewEventsResponder # @example Matching responder does not exist - # Karafka::Responder::Builder(NewBuildsController).build #=> nil + # Karafka::Responder::Builder(NewBuildsConsumer).build #=> nil class Builder - # @param controller_class [Karafka::BaseController, nil] descendant of - # Karafka::BaseController - # @example Tries to find a responder that matches a given controller. If nothing found, - # will return nil (nil is accepted, because it means that a given controller don't + # @param consumer_class [Karafka::BaseConsumer, nil] descendant of + # Karafka::BaseConsumer + # @example Tries to find a responder that matches a given consumer. If nothing found, + # will return nil (nil is accepted, because it means that a given consumer don't # pipe stuff further on) - def initialize(controller_class) - @controller_class = controller_class + def initialize(consumer_class) + @consumer_class = consumer_class end - # Tries to figure out a responder based on a controller class name + # Tries to figure out a responder based on a consumer class name # @return [Class] Responder class (not an instance) # @return [nil] or nil if there's no matching responding class def build Helpers::ClassMatcher.new( - @controller_class, - from: 'Controller', + @consumer_class, + from: 'Consumer', to: 'Responder' ).match end end end