24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/mongo_mapper/plugins/callbacks.rb', line 24
def define_callbacks(*callbacks)
callbacks.each do |callback|
class_eval " def self.\#{callback}(*methods, &block)\n callbacks = CallbackChain.build(:\#{callback}, *methods, &block)\n @\#{callback}_callbacks ||= CallbackChain.new\n @\#{callback}_callbacks.concat callbacks\n end\n\n def self.\#{callback}_callback_chain\n @\#{callback}_callbacks ||= CallbackChain.new\n\n if superclass.respond_to?(:\#{callback}_callback_chain)\n CallbackChain.new(\n superclass.\#{callback}_callback_chain +\n @\#{callback}_callbacks\n )\n else\n @\#{callback}_callbacks\n end\n end\n end_eval\n end\nend\n"
|