Skip to content

Instantly share code, notes, and snippets.

@mctaylorpants
Created March 26, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mctaylorpants/6bcfb5e88e9bd2e1c1f83b33ea7654e1 to your computer and use it in GitHub Desktop.
Save mctaylorpants/6bcfb5e88e9bd2e1c1f83b33ea7654e1 to your computer and use it in GitHub Desktop.
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