Class: Karafka::Routing::Proxy
- Inherits:
-
Object
- Object
- Karafka::Routing::Proxy
- Defined in:
- lib/karafka/routing/proxy.rb
Overview
Proxy is used as a translation layer in between the DSL and raw topic and consumer group objects.
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(target, &block) ⇒ Proxy
constructor
A new instance of Proxy.
-
#method_missing(method_name, *arguments, &block) ⇒ Object
Translates the no “=” DSL of routing into elements assignments on target.
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Tells whether or not a given element exists on the target.
Constructor Details
#initialize(target, &block) ⇒ Proxy
Returns a new instance of Proxy.
21 22 23 24 |
# File 'lib/karafka/routing/proxy.rb', line 21 def initialize(target, &block) @target = target instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
Translates the no “=” DSL of routing into elements assignments on target
30 31 32 33 34 |
# 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 |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/karafka/routing/proxy.rb', line 8 def target @target end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Tells whether or not a given element exists on the target
39 40 41 42 43 |
# 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 |