Methods
Public Class methods
[ show source ]
# File activesupport/lib/active_support/callbacks.rb, line 80 80: def self.build(kind, *methods, &block) 81: methods, options = extract_options(*methods, &block) 82: methods.map! { |method| Callback.new(kind, method, options) } 83: new(methods) 84: end
Public Instance methods
[ show source ]
# File activesupport/lib/active_support/callbacks.rb, line 113 113: def delete(callback) 114: super(callback.is_a?(Callback) ? callback : find(callback)) 115: end
[ show source ]
# File activesupport/lib/active_support/callbacks.rb, line 109 109: def find(callback, &block) 110: select { |c| c == callback && (!block_given? || yield(c)) }.first 111: end
TODO: Decompose into more Array like behavior
[ show source ]
# File activesupport/lib/active_support/callbacks.rb, line 100 100: def replace_or_append!(chain) 101: if index = index(chain) 102: self[index] = chain 103: else 104: self << chain 105: end 106: self 107: end
[ show source ]
# File activesupport/lib/active_support/callbacks.rb, line 86 86: def run(object, options = {}, &terminator) 87: enumerator = options[:enumerator] || :each 88: 89: unless block_given? 90: send(enumerator) { |callback| callback.call(object) } 91: else 92: send(enumerator) do |callback| 93: result = callback.call(object) 94: break result if terminator.call(result, object) 95: end 96: end 97: end