123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::Callbacks::CallTemplate

Do not use. This module is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Defined in: activesupport/lib/active_support/callbacks.rb

Overview

A future invocation of user-supplied code (either as a callback, or a condition filter).

Class Method Summary

Class Method Details

.build(filter, callback)

Filters support:

Symbols:: A method to call.
Procs::   A proc to call with the object.
Objects:: An object with a {before_foo} method on it to call.

All of these objects are converted into a CallTemplate and handled the same after this point.

[ GitHub ]

  
# File 'activesupport/lib/active_support/callbacks.rb', line 494

def self.build(filter, callback)
  case filter
  when Symbol
    MethodCall.new(filter)
  when Conditionals::Value
    ProcCall.new(filter)
  when ::Proc
    if filter.arity > 1
      InstanceExec2.new(filter)
    elsif filter.arity > 0
      InstanceExec1.new(filter)
    else
      InstanceExec0.new(filter)
    end
  else
    ObjectCall.new(filter, callback.current_scopes.join("_").to_sym)
  end
end