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.
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/active_support/callbacks.rb', line 533 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 |