Class: Blabber::Blabber
- Inherits:
-
Object
- Object
- Blabber::Blabber
- Defined in:
- lib/blabber.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ Blabber
constructor
A new instance of Blabber.
- #method_missing(method_name, *args) ⇒ Object
- #process_message(message, loglevel, opts) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Blabber
Returns a new instance of Blabber.
8 9 10 11 12 13 14 15 |
# File 'lib/blabber.rb', line 8 def initialize(opts) @channels = opts.keys.map do |channel_name|\ class_object = channel_name.split("::").inject(Object) do |acc, component| acc.const_get(component) end class_object.new(opts[channel_name]) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
17 18 19 |
# File 'lib/blabber.rb', line 17 def method_missing(method_name, *args) (args[0], method_name.to_s.upcase, args[1]) end |
Instance Method Details
#process_message(message, loglevel, opts) ⇒ Object
21 22 23 24 25 |
# File 'lib/blabber.rb', line 21 def (, loglevel, opts) @channels.each do |channel| channel.emit(, loglevel, opts) end end |