lib/couchrest/mixins/callbacks.rb
def define_callbacks(*symbols)
        terminator = symbols.pop if symbols.last.is_a?(String)
        symbols.each do |symbol|
          extlib_inheritable_accessor("_#{symbol}_terminator") { terminator }

          extlib_inheritable_accessor("_#{symbol}_callback") do
            CallbackChain.new(symbol)
          end

          _define_runner(symbol)
          
          # Define more convenient callback methods
          # set_callback(:save, :before) becomes before_save
          [:before, :after, :around].each do |filter|
            self.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
              def self.#{filter}_#{symbol}(*symbols, &blk)
                _alias_callbacks(symbols, blk) do |callback, options|
                  set_callback(:#{symbol}, :#{filter}, callback, options)
                end
              end
            RUBY_EVAL
          end
        end
      end
# Make the _run_save_callbacks method. The generated method takes
# a block that it'll yield to. It'll call the before and around filters
# in order, yield the block, and then run the after filters.
# 
# _run_save_callbacks do
#   save
# end
#
# The _run_save_callbacks method can optionally take a key, which
# will be used to compile an optimized callback method for each
# key. See #define_callbacks for more information.
Make the _run_save_callbacks method. The generated method takes
a block that it'll yield to. It'll call the before and around filters
in order, yield the block, and then run the after filters.

_run_save_callbacks do
save
end

The _run_save_callbacks method can optionally take a key, which
will be used to compile an optimized callback method for each
key. See #define_callbacks for more information.
Make the _run_save_callbacks method . The generated method takes a block that it ' ll yield to . It ' ll call the before and around filters in order yield the block and then run the after filters . _run_save_callbacks do save end The _run_save_callbacks method can optionally take a key which will be used to compile an optimized callback method for each key . See #define_callbacks for more information .
def define_callbacks(*symbols)
        terminator = symbols.pop if symbols.last.is_a?(String)
        symbols.each do |symbol|
          extlib_inheritable_accessor("_#{symbol}_terminator") { terminator }
          extlib_inheritable_accessor("_#{symbol}_callback") do
            CallbackChain.new(symbol)
          end
          _define_runner(symbol)
          [:before, :after, :around].each do |filter|
            self.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
              def self.#{filter}_#{symbol}(*symbols, &blk)
                _alias_callbacks(symbols, blk) do |callback, options|
                  set_callback(:#{symbol}, :#{filter}, callback, options)
                end
              end
            RUBY_EVAL
          end
        end
      end
def define_callbacks ( * symbols ) terminator = symbols . pop if symbols . last . is_a? ( String ) symbols . each do | symbol | extlib_inheritable_accessor ( "_#{symbol}_terminator" ) { terminator } extlib_inheritable_accessor ( "_#{symbol}_callback" ) do CallbackChain . new ( symbol ) end _define_runner ( symbol ) [ :before , :after , :around ] . each do | filter | self . class_eval <<-RUBY_EVAL , __FILE__ , __LINE__ + 1 
              def self. #{ filter } _ #{ symbol } (*symbols, &blk)
                _alias_callbacks(symbols, blk) do |callback, options|
                  set_callback(: #{ symbol } , : #{ filter } , callback, options)
                end
              end
             RUBY_EVAL end end end
Make the _run_save_callbacks method.
Make the _run_save_callbacks method .
# Define more convenient callback methods # set_callback(:save, :before) becomes before_save
symbols