public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Revert "Run callbacks from object's metaclass"
josh (author)
Wed Jul 16 18:23:44 -0700 2008
commit  d8a72b32c5b0c32abf257f05b89bad7d21f178ec
tree    d4e9fb6ec455589164459cdc2f5ae35765c95c72
parent  40dbebba28bfa1c55737da7354542c3bdca4e1a1
...
1
2
3
4
5
6
7
...
1
2
 
 
3
4
5
0
@@ -1,7 +1,5 @@
0
 *Edge*
0
 
0
-* Run callbacks from object's metaclass [Josh Peek]
0
-
0
 * Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example:
0
   
0
   a = (1..10).to_a
...
269
270
271
272
273
274
275
276
277
278
279
280
 
281
282
283
...
269
270
271
 
 
 
 
 
 
 
 
 
272
273
274
275
0
@@ -269,15 +269,7 @@ module ActiveSupport
0
     # pass
0
     # stop
0
     def run_callbacks(kind, options = {}, &block)
0
- callback_chain_method = "#{kind}_callback_chain"
0
-
0
- # Meta class inherits Class so we don't have to merge it in 1.9
0
- if RUBY_VERSION >= '1.9'
0
- metaclass.send(callback_chain_method).run(self, options, &block)
0
- else
0
- callbacks = self.class.send(callback_chain_method) | metaclass.send(callback_chain_method)
0
- callbacks.run(self, options, &block)
0
- end
0
+ self.class.send("#{kind}_callback_chain").run(self, options, &block)
0
     end
0
   end
0
 end
...
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
...
84
85
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
88
89
0
@@ -84,30 +84,6 @@ class CallbacksTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class MetaclassCallbacksTest < Test::Unit::TestCase
0
- module ModuleWithCallbacks
0
- def self.extended(object)
0
- object.metaclass.before_save :raise_metaclass_callback_called
0
- end
0
-
0
- def module_callback_called?
0
- @module_callback_called ||= false
0
- end
0
-
0
- def raise_metaclass_callback_called
0
- @module_callback_called = true
0
- end
0
- end
0
-
0
- def test_metaclass_callbacks
0
- person = Person.new
0
- person.extend(ModuleWithCallbacks)
0
- assert !person.module_callback_called?
0
- person.save
0
- assert person.module_callback_called?
0
- end
0
-end
0
-
0
 class ConditionalCallbackTest < Test::Unit::TestCase
0
   def test_save_conditional_person
0
     person = ConditionalPerson.new

Comments

    No one has commented yet.