class Karafka::Routing::Proxy
Proxy
is used as a translation layer in between the DSL and raw topic and consumer group objects.
Constants
- IGNORED_POSTFIXES
We should proxy only non ? and = methods as we want to have a regular dsl
Attributes
target[R]
Public Class Methods
new(target, &block)
click to toggle source
@param target [Object] target object to which we proxy any DSL call @param block [Proc] block that we want to evaluate in the proxy context
# File lib/karafka/routing/proxy.rb, line 21 def initialize(target, &block) @target = target instance_eval(&block) end
Public Instance Methods
method_missing(method_name, *arguments, &block)
click to toggle source
Translates the no “=” DSL of routing into elements assignments on target @param method_name [Symbol] name of the missing method @param arguments [Array] array with it's arguments @param block [Proc] block provided to the method
Calls superclass method
# File lib/karafka/routing/proxy.rb, line 30 def method_missing(method_name, *arguments, &block) return super unless respond_to_missing?(method_name) @target.public_send(:"#{method_name}=", *arguments, &block) end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Tells whether or not a given element exists on the target @param method_name [Symbol] name of the missing method @param include_private [Boolean] should we include private in the check as well
Calls superclass method
# File lib/karafka/routing/proxy.rb, line 39 def respond_to_missing?(method_name, include_private = false) return false if IGNORED_POSTFIXES.any? { |postfix| method_name.to_s.end_with?(postfix) } @target.respond_to?(:"#{method_name}=", include_private) || super end