Module: Flipper::Notifications

Defined in:
lib/flipper/notifications.rb,
lib/flipper/notifications/railtie.rb,
lib/flipper/notifications/version.rb,
lib/flipper/notifications/webhooks.rb,
lib/flipper/notifications/configuration.rb,
lib/flipper/notifications/feature_event.rb,
lib/flipper/notifications/webhooks/slack.rb,
lib/flipper/notifications/webhooks/errors.rb,
lib/flipper/notifications/event_serializer.rb,
lib/flipper/notifications/webhooks/webhook.rb,
lib/flipper/notifications/features_subscriber.rb,
lib/flipper/notifications/webhooks/serializer.rb,
lib/flipper/notifications/notifiers/webhook_notifier.rb,
lib/flipper/notifications/jobs/webhook_notification_job.rb

Defined Under Namespace

Modules: Notifiers, Webhooks Classes: Configuration, Error, EventSerializer, FeatureEvent, FeaturesSubscriber, Railtie, WebhookNotificationJob

Constant Summary collapse

VERSION =
"0.1.8"

Class Method Summary collapse

Class Method Details

.configurationObject



23
24
25
# File 'lib/flipper/notifications.rb', line 23

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



19
20
21
# File 'lib/flipper/notifications.rb', line 19

def configure
  yield configuration if block_given?
end

.disabledObject

WARNING: this implementation is not thread-safe



43
44
45
46
47
48
49
# File 'lib/flipper/notifications.rb', line 43

def disabled
  previous_value = configuration.enabled
  configuration.enabled = false
  yield
ensure
  configuration.enabled = previous_value
end

.notify(event:) ⇒ Object



27
28
29
# File 'lib/flipper/notifications.rb', line 27

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

.subscribe!Object



31
32
33
34
35
36
# File 'lib/flipper/notifications.rb', line 31

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

.unsubscribe!Object



38
39
40
# File 'lib/flipper/notifications.rb', line 38

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