class FeatureFlagger::Notifier
Constants
- RELEASE
- RELEASE_TO_ALL
- UNRELEASE
- UNRELEASE_TO_ALL
Attributes
notify[R]
Public Class Methods
new(notify = nil)
click to toggle source
# File lib/feature_flagger/notifier.rb, line 10 def initialize(notify = nil) @notify = valid_notify?(notify) ? notify : nullNotify end
Public Instance Methods
send(operation, feature_key, resource_id = nil)
click to toggle source
# File lib/feature_flagger/notifier.rb, line 14 def send(operation, feature_key, resource_id = nil) @notify.call(build_event(operation, extract_resource_from_key(feature_key), feature_key, resource_id)) end
Private Instance Methods
build_event(operation, resource_name, feature_key, resource_id)
click to toggle source
# File lib/feature_flagger/notifier.rb, line 36 def build_event(operation, resource_name, feature_key, resource_id) { type: operation, model: resource_name, feature: feature_key, id: resource_id } end
extract_resource_from_key(key)
click to toggle source
# File lib/feature_flagger/notifier.rb, line 28 def extract_resource_from_key(key) Storage::Keys.extract_resource_name_from_feature_key( key ) rescue FeatureFlagger::Storage::Keys::InvalidResourceNameError "legacy key" end
nullNotify()
click to toggle source
# File lib/feature_flagger/notifier.rb, line 20 def nullNotify lambda {|e| } end
valid_notify?(notify)
click to toggle source
# File lib/feature_flagger/notifier.rb, line 24 def valid_notify?(notify) !notify.nil? && notify.is_a?(Proc) end