跳至内容 跳至搜索
方法
E
I
M
N

类公共方法

new(method)

# File activesupport/lib/active_support/callbacks.rb, line 380
def initialize(method)
  @method_name = method
end

实例公共方法

expand(target, value, block)

返回执行此调用所需的各个部分,以及给定的输入值。

返回一个形式为

[target, block, method, *arguments]

此数组可以按以下方式使用

target.send(method, *arguments, &block)

实际的调用留给调用者来执行,以最大程度地减少调用堆栈污染。

# File activesupport/lib/active_support/callbacks.rb, line 397
def expand(target, value, block)
  [target, block, @method_name]
end

inverted_lambda()

# File activesupport/lib/active_support/callbacks.rb, line 407
def inverted_lambda
  lambda do |target, value, &block|
    !target.send(@method_name, &block)
  end
end

make_lambda()

# File activesupport/lib/active_support/callbacks.rb, line 401
def make_lambda
  lambda do |target, value, &block|
    target.send(@method_name, &block)
  end
end