Sha256: 7576f4a6c14107db59f1f0e4e089eca2ad5811325108f90e118ac1b0b0aa7e90

Contents?: true

Size: 1017 Bytes

Versions: 7

Compression:

Stored size: 1017 Bytes

Contents

# frozen_string_literal: true

require "active_support/notifications"
require "flipper/notifications/version"

require_relative "notifications/configuration"
require_relative "notifications/feature_event"
require_relative "notifications/features_subscriber"
require_relative "notifications/webhooks"

module Flipper
  module Notifications
    class Error < StandardError; end

    module_function

    @subscriber = nil

    def configure
      yield configuration if block_given?
    end

    def configuration
      @configuration ||= Configuration.new
    end

    def notify(event:)
      configuration.notifiers.each { |notifier| notifier.call(event: event) }
    end

    def subscribe!
      @subscriber = ActiveSupport::Notifications.subscribe(
        Flipper::Feature::InstrumentationName,
        FeaturesSubscriber.new
      )
    end

    def unsubscribe!
      ActiveSupport::Notifications.unsubscribe(@subscriber)
    end
  end
end

require_relative "notifications/railtie" if defined?(Rails::Railtie)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
flipper-notifications-0.1.6 lib/flipper/notifications.rb
flipper-notifications-0.1.5 lib/flipper/notifications.rb
flipper-notifications-0.1.4 lib/flipper/notifications.rb
flipper-notifications-0.1.3 lib/flipper/notifications.rb
flipper-notifications-0.1.2 lib/flipper/notifications.rb
flipper-notifications-0.1.1 lib/flipper/notifications.rb
flipper-notifications-0.1.0 lib/flipper/notifications.rb