lib/couchrest/mixins/callbacks.rb
# This will supply contents for before and around filters, and no
# contents for after filters (for the forward pass).
This will supply contents for before and around filters, and no
contents for after filters (for the forward pass).
This will supply contents for before and around filters and no contents for after filters ( for the forward pass ) .
def start(key = nil, options = {})
        object, terminator = (options || {}).values_at(:object, :terminator)
        return if key && !object.send("_one_time_conditions_valid_{@callback_id}?")
        terminator ||= false
        if @kind == :before || @kind == :around
          if @kind == :before
            filter = <<-RUBY_EVAL
              unless halted
                result = {@filter}
                halted = ({terminator})
              end
            RUBY_EVAL
            [@compiled_options[0], filter, @compiled_options[1]].compact.join("\n")
          else
             For `around_save :filter_name, :if => :condition':
             def _conditional_callback_save_17
               if condition
                 filter_name do
                   yield self
                 end
               else
                 yield self
               end
            name = "_conditional_callback_{@kind}_{next_id}"
            txt, line = <<-RUBY_EVAL, __LINE__ + 1
              def {name}(halted)
                {@compiled_options[0] || "if true"} && !halted
                  {@filter} do
                    yield self
                  end
                else
                  yield self
                end
              end
            RUBY_EVAL
            @klass.class_eval(txt, __FILE__, line)
            "{name}(halted) do"
          end
        end
      end
def start ( key = nil , options = { } ) object , terminator = ( options || { } ) . values_at ( :object , :terminator ) return if key && ! object . send ( "_one_time_conditions_valid_#{@callback_id}?" ) terminator ||= false if @kind == :before || @kind == :around if @kind == :before filter = <<-RUBY_EVAL 
              unless halted
                result =  #{ @filter } 
                halted = ( #{ terminator } )
              end
             RUBY_EVAL [ @compiled_options [ 0 ] , filter , @compiled_options [ 1 ] ] . compact . join ( "\n" ) else name = "_conditional_callback_#{@kind}_#{next_id}" txt , line = <<-RUBY_EVAL , __LINE__ + 1 
              def  #{ name } (halted)
                 #{ @compiled_options [ 0 ] || "if true" }  && !halted
                   #{ @filter }  do
                    yield self
                  end
                else
                  yield self
                end
              end
             RUBY_EVAL @klass . class_eval ( txt , __FILE__ , line ) "#{name}(halted) do" end end end
This will supply contents for before and around filters, and no
contents for after filters (for the forward pass).
This will supply contents for before and around filters and no contents for after filters ( for the forward pass ) .
# options[0] is the compiled form of supplied conditions # options[1] is the "end" for the conditional # if condition    # before_save :filter_name, :if => :condition #   filter_name # end # 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
key
options