Class: Alephant::Logger::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/logger/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(drivers) ⇒ Base



4
5
6
# File 'lib/alephant/logger/base.rb', line 4

def initialize(drivers)
  @drivers = drivers << ::Logger.new(STDOUT)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



12
13
14
15
16
# File 'lib/alephant/logger/base.rb', line 12

def method_missing(name, *args)
  drivers.each do |driver|
    driver.send(name, *args) if driver.respond_to? name
  end
end

Instance Method Details

#respond_to?(name) ⇒ Boolean



18
19
20
21
22
# File 'lib/alephant/logger/base.rb', line 18

def respond_to?(name)
  drivers.any? do |driver|
    driver.respond_to?(name) || super
  end
end

#write(*args) ⇒ Object



8
9
10
# File 'lib/alephant/logger/base.rb', line 8

def write(*args)
  self.<< *args
end