Sha256: c642417f8b9e7c2ce1d5d104f7ba38d4a200543be4d0d01773d3f043a93c97a8

Contents?: true

Size: 485 Bytes

Versions: 3

Compression:

Stored size: 485 Bytes

Contents

# frozen_string_literal: true

module AbstractNotifier
  module AsyncAdapters
    class << self
      def lookup(adapter, options = nil)
        return adapter unless adapter.is_a?(Symbol)

        adapter_class_name = adapter.to_s.split("_").map(&:capitalize).join
        AsyncAdapters.const_get(adapter_class_name).new(options || {})
      rescue NameError => e
        raise e.class, "Notifier async adapter :#{adapter} haven't been found", e.backtrace
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abstract_notifier-0.2.0 lib/abstract_notifier/async_adapters.rb
abstract_notifier-0.1.1 lib/abstract_notifier/async_adapters.rb
abstract_notifier-0.1.0 lib/abstract_notifier/async_adapters.rb