Created
March 26, 2020 18:57
-
-
Save mctaylorpants/6bcfb5e88e9bd2e1c1f83b33ea7654e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.halting(callback_sequence, user_callback, halted_lambda, filter) | |
callback_sequence.before do |env| | |
target = env.target | |
value = env.value | |
halted = env.halted | |
unless halted | |
result_lambda = -> { user_callback.call target, value } | |
env.halted = halted_lambda.call(target, result_lambda) | |
if env.halted | |
target.send :halted_callback_hook, filter | |
end | |
end | |
env | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Originally from https://github.com/rails/rails/blob/c4d3e202e10ae627b3b9c34498afb45450652421/activesupport/lib/active_support/callbacks.rb#L162-L179