Symbols::Amethodtocall.Strings::Somecontenttoevaluate.Procs::Aproctocallwiththeobject.Objects::Anobjectwitha<tt>before_foo</tt> method on it to call.
All of these objects are compiled into methods and handled the same after
this point:
Symbols::Alreadymethods.Strings::class_eval'd into methods.
Procs:: using define_method compiled into methods.
Objects::
a method is created that calls the before_foo method
on the object.
# File activesupport/lib/active_support/callbacks.rb, line 421
def make_lambda(filter)
case filter
when Symbol
lambda { |target, _, &blk| target.send filter, &blk }
when String
l = eval "lambda { |value| #{filter} }"
lambda { |target, value| target.instance_exec(value, &l) }
when Conditionals::Value then filter
when ::Proc
if filter.arity > 1
return lambda { |target, _, &block|
raise ArgumentError unless block
target.instance_exec(target, block, &filter)
}
end
if filter.arity <= 0
lambda { |target, _| target.instance_exec(&filter) }
else
lambda { |target, _| target.instance_exec(target, &filter) }
end
else
scopes = Array(chain_config[:scope])
method_to_call = scopes.map{ |s| public_send(s) }.join("_")
lambda { |target, _, &blk|
filter.public_send method_to_call, target, &blk
}
end
end