class ActiveSupport::Callbacks::Callback
def start(key=nil, object=nil)
This will supply contents for before and around filters, and no
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 <<-RUBY_EVAL 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 RUBY_EVAL 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 <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def #{name}(halted) if #{@compiled_options} && !halted #{@filter} do yield self end else yield self end end RUBY_EVAL "#{name}(halted) do" end end