Sha256: cb417f2edd3fe1f444b47a84ceed449abfb8007e580a48d9813059749341bb29

Contents?: true

Size: 594 Bytes

Versions: 2

Compression:

Stored size: 594 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.titleize.gsub(' ', '')}".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

2 entries across 2 versions & 1 rubygems

Version Path
multi_notifier-0.4.0 lib/multi_notifier/builder.rb
multi_notifier-0.3.0 lib/multi_notifier/builder.rb