Sha256: f11ff6f4cd3588af8f806d79a1e92729d75a9d90df5b4e1a410f85fd2ccbb4cb

Contents?: true

Size: 673 Bytes

Versions: 2

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

require_relative 'notifier/honeybadger_strategy'
require_relative 'notifier/null_strategy'
require_relative 'notifier/raise_strategy'

module JunkDrawer
  # class to send dev notifications to different channels
  class Notifier

    include Callable

    class << self

      attr_reader :strategy

      def strategy=(strategy)
        @strategy =
          strategy.is_a?(Symbol) ? STRATEGIES.fetch(strategy) : strategy
      end

    end

    STRATEGIES = {
      honeybadger: HoneybadgerStrategy,
      raise: RaiseStrategy,
      null: NullStrategy,
    }.freeze

    def call(*args)
      self.class.strategy.(*args)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
junk_drawer-1.8.0 lib/junk_drawer/notifier.rb
junk_drawer-1.7.0 lib/junk_drawer/notifier.rb