Class: Hato::Observer

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Observer

Returns a new instance of Observer.



5
6
7
# File 'lib/hato/observer.rb', line 5

def initialize(config)
  @config = config
end

Instance Method Details

#update(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hato/observer.rb', line 9

def update(args)
  logger  = args.delete(:logger)
  plugins = load_plugins_for(args[:tag])

  plugins.each do |plugin|
    Thread.start(plugin) do |t|
      begin
        t.notify(args)
      rescue => e
        logger.error("#{e.message} from #{t.class}")
      end
    end
  end
end