Class: Karafka::Helpers::MultiDelegator
- Inherits:
-
Object
- Object
- Karafka::Helpers::MultiDelegator
- Defined in:
- lib/karafka/helpers/multi_delegator.rb
Overview
Note:
Taken from stackoverflow.com/questions/6407141
Multidelegator is used to delegate calls to multiple targets.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*targets) ⇒ MultiDelegator
constructor
A new instance of MultiDelegator.
Constructor Details
#initialize(*targets) ⇒ MultiDelegator
Returns a new instance of MultiDelegator.
10 11 12 |
# File 'lib/karafka/helpers/multi_delegator.rb', line 10 def initialize(*targets) @targets = targets end |
Class Method Details
.delegate(*methods) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/karafka/helpers/multi_delegator.rb', line 18 def delegate(*methods) methods.each do |m| define_method(m) do |*args| @targets.map { |t| t.send(m, *args) } end end self end |