Class: EventHub::Components::MultiLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/eventhub/components/multi_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder = nil) ⇒ MultiLogger

Returns a new instance of MultiLogger.



4
5
6
# File 'lib/eventhub/components/multi_logger.rb', line 4

def initialize(folder = nil)
  @devices = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



16
17
18
19
20
21
22
23
# File 'lib/eventhub/components/multi_logger.rb', line 16

def method_missing(method, *args, &block)
  devices.map do |target|
    target.send(method, *args, &block)
  rescue => e
    warn "WARNING: Could not call #{method} in #{target} with #{args} because of #{e.message}"
    e
  end
end

Instance Attribute Details

#devicesObject

Returns the value of attribute devices.



2
3
4
# File 'lib/eventhub/components/multi_logger.rb', line 2

def devices
  @devices
end

Instance Method Details

#add_device(device) ⇒ Object

Raises:

  • (::ArgumentError)


8
9
10
11
12
# File 'lib/eventhub/components/multi_logger.rb', line 8

def add_device(device)
  raise ::ArgumentError.new("can not add nil device") if device.nil?
  @devices << device
  self
end