module Gitlab::Experiment::Callbacks

Public Instance Methods

build_callback(chain, filters, **options) { |target, result_lambda| ... } click to toggle source
# File lib/gitlab/experiment/callbacks.rb, line 20
def build_callback(chain, filters, **options)
  filters = filters.compact.map do |filter|
    result_lambda = ActiveSupport::Callbacks::CallTemplate.build(filter, self).make_lambda
    ->(target) { yield(target, result_lambda) }
  end

  raise ArgumentError, 'no filters provided' if filters.empty?

  set_callback(chain, *filters, **options)
end