class ActiveSupport::Callbacks::Filters::Before
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_support/callbacks.rbs class ActiveSupport::Callbacks::Filters::Before def self.halting: (ActiveSupport::Callbacks::CallbackSequence callback_sequence, Proc user_callback, Proc halted_lambda, Symbol filter, Symbol name) -> ActiveSupport::Callbacks::CallbackSequence end
def self.build(callback_sequence, user_callback, user_conditions, chain_config, filter, name)
def self.build(callback_sequence, user_callback, user_conditions, chain_config, filter, name) halted_lambda = chain_config[:terminator] if user_conditions.any? halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter, name) else halting(callback_sequence, user_callback, halted_lambda, filter, name) end end
def self.halting(callback_sequence, user_callback, halted_lambda, filter, name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def self.halting: (ActiveSupport::Callbacks::CallbackSequence callback_sequence, Proc user_callback, Proc halted_lambda, Symbol filter, Symbol name) -> ActiveSupport::Callbacks::CallbackSequence
This signature was generated using 1 sample from 1 application.
def self.halting(callback_sequence, user_callback, halted_lambda, filter, name) 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, name end end env end end
def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter, name)
def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter, name) callback_sequence.before do |env| target = env.target value = env.value halted = env.halted if !halted && user_conditions.all? { |c| c.call(target, value) } result_lambda = -> { user_callback.call target, value } env.halted = halted_lambda.call(target, result_lambda) if env.halted target.send :halted_callback_hook, filter, name end end env end end