Class: MultiLogging

Inherits:
Object
  • Object
show all
Defined in:
lib/multi-logging.rb,
lib/multi_logging/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*loggers) ⇒ MultiLogging

Returns a new instance of MultiLogging.



6
7
8
# File 'lib/multi-logging.rb', line 6

def initialize(*loggers)
  @loggers = loggers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/multi-logging.rb', line 10

def method_missing(method_name, *args, &block)
  result = nil

  @loggers.each do |logger|
    result = logger.send(method_name, *args, &block)
  end

  result
end

Instance Attribute Details

#loggersObject

Returns the value of attribute loggers.



4
5
6
# File 'lib/multi-logging.rb', line 4

def loggers
  @loggers
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/multi-logging.rb', line 20

def respond_to_missing?(method_name, include_private = false)
  @loggers.first.respond_to?(method_name, include_private) || super
end