Sha256: a9a0065eebb2ede5c97f97232f2cf45f7c5d545a4dc674da01925fe6290db90c

Contents?: true

Size: 579 Bytes

Versions: 8

Compression:

Stored size: 579 Bytes

Contents

# Container to allow writes to multiple devices

# Code originally from:
# http://stackoverflow.com/a/6410202

module LogStashLogger
  module Device
    class MultiDelegator < Base
      attr_reader :devices

      def initialize(*devices)
        @io = self
        @devices = devices
        self.class.delegate(:write, :close, :flush)
      end

      private

      def self.delegate(*methods)
        methods.each do |m|
          define_method(m) do |*args|
            @devices.each { |device| device.send(m, *args) }
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logstash-logger-0.12.0 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.11.0 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.10.3 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.10.2 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.10.1 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.10.0 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.9.0 lib/logstash-logger/device/multi_delegator.rb
logstash-logger-0.8.0 lib/logstash-logger/device/multi_delegator.rb