Sha256: 799b4a758835341554d7e5305730d85d67052664a80bddf41f9a3d6c216a27eb

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

require "active_support"

module MultiNotifier
  class Builder
    attr_reader :adapters

    def initialize
      @adapters = []
    end

    def use(type, configs = {})
      require "multi_notifier/middlewares/#{type}"
      adapter = "MultiNotifier::Middlewares::#{type.to_s.classify}".constantize
      adapters << adapter.new(configs)

      adapter
    end

    def notify_all!
      adapters.each do |adapter|
        begin
          adapter.notify!
        rescue => e
          puts "#{adapter.class.name} has error #{e.inspect}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_notifier-0.2.0 lib/multi_notifier/builder.rb