method
start
rails latest stable - Class:
ActiveSupport::Callbacks::Callback
Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v3.2.13) is shown here.
start(key=nil, object=nil)public
This will supply contents for before and around filters, and no contents for after filters (for the forward pass).
# File activesupport/lib/active_support/callbacks.rb, line 171
def start(key=nil, object=nil)
return if key && !object.send("_one_time_conditions_valid_#{@callback_id}?")
# options[0] is the compiled form of supplied conditions
# options[1] is the "end" for the conditional
#
case @kind
when :before
# if condition # before_save :filter_name, :if => :condition
# filter_name
# end
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
when :around
# Compile around filters with conditions into proxy methods
# that contain the conditions.
#
# For `around_save :filter_name, :if => :condition':
#
# def _conditional_callback_save_17
# if condition
# filter_name do
# yield self
# end
# else
# yield self
# end
# end
#
name = "_conditional_callback_#{@kind}_#{next_id}"
@klass.class_eval def #{name}(halted) if #{@compiled_options} && !halted #{@filter} do yield self end else yield self end end, __FILE__, __LINE__ + 1
"#{name}(halted) do"
end
end Related methods
- Instance methods
- _compile_per_key_options
- _update_filter
- clone
- end
- matches?
- name
- next_id
- normalize_options!
- recompile!
- start
- Class methods
- new
- Private methods
-
_compile_filter -
_compile_options -
_normalize_legacy_filter