跳到內容 跳到搜尋
方法
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