Sha256: 802e3f2e521937efa5cd449a3e5aeaa637126874e6293265d7eb4b7abce300ab
Contents?: true
Size: 924 Bytes
Versions: 27
Compression:
Stored size: 924 Bytes
Contents
# frozen_string_literal: true module Karafka # Module containing classes and methods that provide some additional functionalities module Helpers # @note Taken from http://stackoverflow.com/questions/6407141 # Multidelegator is used to delegate calls to multiple targets class MultiDelegator # @param targets to which we want to delegate methods def initialize(*targets) @targets = targets end class << self # @param methods names that should be delegated to # @example Delegate write and close to STDOUT and file # Logger.new MultiDelegator.delegate(:write, :close).to(STDOUT, log_file) def delegate(*methods) methods.each do |m| define_method(m) do |*args| @targets.map { |t| t.send(m, *args) } end end self end alias to new end end end end
Version data entries
27 entries across 27 versions & 1 rubygems