Parent

Methods

Class/Module Index [+]

Quicksearch

ActiveSupport::Callbacks::CallbackChain

An Array with a compile method

Attributes

config[R]
name[R]

Public Class Methods

new(name, config) click to toggle source
# File lib/active_support/callbacks.rb, line 341
def initialize(name, config)
  @name = name
  @config = {
    :terminator => "false",
    :rescuable => false,
    :scope => [ :kind ]
  }.merge(config)
end

Public Instance Methods

compile(key=nil, object=nil) click to toggle source
# File lib/active_support/callbacks.rb, line 350
def compile(key=nil, object=nil)
  method = []
  method << "value = nil"
  method << "halted = false"

  each do |callback|
    method << callback.start(key, object)
  end

  if config[:rescuable]
    method << "rescued_error = nil"
    method << "begin"
  end

  method << "value = yield if block_given? && !halted"

  if config[:rescuable]
    method << "rescue Exception => e"
    method << "rescued_error = e"
    method << "end"
  end

  reverse_each do |callback|
    method << callback.end(key, object)
  end

  method << "raise rescued_error if rescued_error" if config[:rescuable]
  method << "halted ? false : (block_given? ? value : true)"
  method.compact.join("\n")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.