Class: Blabber::Blabber

Inherits:
Object
  • Object
show all
Defined in:
lib/blabber.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Blabber

Returns a new instance of Blabber.



8
9
10
11
12
13
14
15
16
# File 'lib/blabber.rb', line 8

def initialize(opts)
  @channels = Array.new
  opts.each do |channel|\
    class_object = channel["channel"].split("::").inject(Object) do |acc, component|
      acc.const_get(component)
    end
    @channels << class_object.new(channel)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



18
19
20
# File 'lib/blabber.rb', line 18

def method_missing(method_name, *args)
  process_message(args[0], method_name.to_s.upcase, args[1])
end

Instance Method Details

#process_message(message, loglevel, opts) ⇒ Object



22
23
24
25
26
# File 'lib/blabber.rb', line 22

def process_message(message, loglevel, opts)
  @channels.each do |channel|
    channel.emit(message, loglevel, opts)
  end
end