method
apply
v4.0.2 -
Show latest stable
- Class:
ActiveSupport::Callbacks::Callback
apply(code)public
Wraps code with filter
# File activesupport/lib/active_support/callbacks.rb, line 156
def apply(code)
case @kind
when :before
if !halted && #{@compiled_options} # This double assignment is to prevent warnings in 1.9.3 as # the `result` variable is not always used except if the # terminator code refers to it. result = result = #{@filter} halted = (#{chain.config[:terminator]}) if halted halted_callback_hook(#{@raw_filter.inspect.inspect}) end end #{code}
when :after
#{code} if #{!chain.config[:skip_after_callbacks_if_terminated] || "!halted"} && #{@compiled_options} #{@filter} end
when :around
name = define_conditional_callback
#{name}(halted) do #{code} value end
end
end Related methods
- Instance methods
- _update_filter
- apply
- clone
- deprecate_per_key_option
- duplicates?
- matches?
- name
- next_id
- normalize_options!
- recompile!
- Class methods
- new
- Private methods
-
_compile_filter -
_normalize_legacy_filter -
define_conditional_callback -
recompile_options!