lib/couchrest/mixins/callbacks.rb
# Define callbacks.
#
# Creates a <name>_callback method that you can use to add callbacks.
#
# Syntax:
#   save_callback :before, :before_meth
#   save_callback :after,  :after_meth, :if => :condition
#   save_callback :around {|r| stuff; yield; stuff }
#
# The <name>_callback method also updates the _run_<name>_callbacks
# method, which is the public API to run the callbacks.
#
# Also creates a skip_<name>_callback method that you can use to skip
# callbacks.
#
# When creating or skipping callbacks, you can specify conditions that
# are always the same for a given key. For instance, in ActionPack,
# we convert :only and :except conditions into per-key conditions.
#
#   before_filter :authenticate, :except => "index"
# becomes
#   dispatch_callback :before, :authenticate, :per_key => {:unless => proc {|c| c.action_name == "index"}}
#
# Per-Key conditions are evaluated only once per use of a given key.
# In the case of the above example, you would do:
#
#   run_dispatch_callbacks(action_name) { ... dispatch stuff ... }
#
# In that case, each action_name would get its own compiled callback
# method that took into consideration the per_key conditions. This
# is a speed improvement for ActionPack.
Define callbacks.
Creates a _callback method that you can use to add callbacks.



The _callback method also updates the _run__callbacks
method, which is the public API to run the callbacks.

Also creates a skip__callback method that you can use to skip
callbacks.

When creating or skipping callbacks, you can specify conditions that
are always the same for a given key. For instance, in ActionPack,
we convert :only and :except conditions into per-key conditions.



Per-Key conditions are evaluated only once per use of a given key.
In the case of the above example, you would do.



In that case, each action_name would get its own compiled callback
method that took into consideration the per_key conditions. This
is a speed improvement for ActionPack.
Define callbacks . Creates a _callback method that you can use to add callbacks . The _callback method also updates the _run__callbacks method which is the public API to run the callbacks . Also creates a skip__callback method that you can use to skip callbacks . When creating or skipping callbacks you can specify conditions that are always the same for a given key . For instance in ActionPack we convert : only and : except conditions into per - key conditions . Per - Key conditions are evaluated only once per use of a given key . In the case of the above example you would do . In that case each action_name would get its own compiled callback method that took into consideration the per_key conditions . This is a speed improvement for ActionPack .
def _update_callbacks(name, filters = CallbackChain.new(name), block = nil)
        type = [:before, :after, :around].include?(filters.first) ? filters.shift : :before
        options = filters.last.is_a?(Hash) ? filters.pop : {}
        filters.unshift(block) if block
        callbacks = send("_#{name}_callback")
        yield callbacks, type, filters, options if block_given?
        _define_runner(name)
      end
def _update_callbacks ( name , filters = CallbackChain . new ( name ) , block = nil ) type = [ :before , :after , :around ] . include? ( filters . first ) ? filters . shift : :before options = filters . last . is_a? ( Hash ) ? filters . pop : { } filters . unshift ( block ) if block callbacks = send ( "_#{name}_callback" ) yield callbacks , type , filters , options if block_given? _define_runner ( name ) end
Define callbacks.
Define callbacks .
name
filters
new
block