Class: EventHub::Components::MultiLogger
- Inherits:
-
Object
- Object
- EventHub::Components::MultiLogger
- Defined in:
- lib/eventhub/components/multi_logger.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
Returns the value of attribute devices.
Instance Method Summary collapse
- #add_device(device) ⇒ Object
-
#initialize(folder = nil) ⇒ MultiLogger
constructor
A new instance of MultiLogger.
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.}" e end end |
Instance Attribute Details
#devices ⇒ Object
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
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 |