Sha256: 639a2dd4968a5e958bd6028c5b6f6ca4337c2ae680894ef4548f94d93fe864d9

Contents?: true

Size: 693 Bytes

Versions: 4

Compression:

Stored size: 693 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, **kwargs)
      self.class.strategy.(*args, **kwargs)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
junk_drawer-2.1.2 lib/junk_drawer/notifier.rb
junk_drawer-2.1.1 lib/junk_drawer/notifier.rb
junk_drawer-2.1.0 lib/junk_drawer/notifier.rb
junk_drawer-2.0.0 lib/junk_drawer/notifier.rb