Module: ActiveSupport::Callbacks::CallTemplate
- Defined in:
- lib/active_support/callbacks.rb
Overview
A future invocation of user-supplied code (either as a callback, or a condition filter).
Defined Under Namespace
Classes: InstanceExec0, InstanceExec1, InstanceExec2, MethodCall, ObjectCall, ProcCall
Class Method Summary collapse
-
.build(filter, callback) ⇒ Object
Filters support:.
Class Method Details
.build(filter, callback) ⇒ Object
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.
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/active_support/callbacks.rb', line 495 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 |