Sha256: e4252f545b0f0911ff809ed24281f72c748f37f7b085d9a582d1526c25e206c4
Contents?: true
Size: 908 Bytes
Versions: 27
Compression:
Stored size: 908 Bytes
Contents
# Quick example of how to keep track of when a feature was last checked. require 'bundler/setup' require 'securerandom' require 'active_support/isolated_execution_state' require 'active_support/notifications' require 'flipper' class FlipperSubscriber def self.stats @stats ||= {} end def call(name, start, finish, id, payload) if payload[:operation] == :enabled? feature_name = payload.fetch(:feature_name) self.class.stats[feature_name] = Time.now end end ActiveSupport::Notifications.subscribe(/feature_operation.flipper/, new) end Flipper.configure do |config| config.default { Flipper.new(config.adapter, instrumenter: ActiveSupport::Notifications) } end Flipper.enabled?(:search) Flipper.enabled?(:booyeah) Flipper.enabled?(:hooray) sleep 1 Flipper.enabled?(:booyeah) Flipper.enabled?(:hooray) sleep 1 Flipper.enabled?(:hooray) pp FlipperSubscriber.stats
Version data entries
27 entries across 27 versions & 1 rubygems