build(filter, callback)
public
Filters support:
Symbols:: A method to call.
Procs:: A proc to call with the object.
Objects:: An object with a <tt>before_foo</tt> method on it to call.
All of
these objects are converted into a CallTemplate and handled the same after
this point.
# File activesupport/lib/active_support/callbacks.rb, line 447
def self.build(filter, callback)
case filter
when Symbol
new(nil, filter, [], nil)
when Conditionals::Value
new(filter, :call, [:target, :value], nil)
when ::Proc
if filter.arity > 1
new(nil, :instance_exec, [:target, :block], filter)
elsif filter.arity > 0
new(nil, :instance_exec, [:target], filter)
else
new(nil, :instance_exec, [], filter)
end
else
method_to_call = callback.current_scopes.join("_")
new(filter, method_to_call, [:target], nil)
end
end