This project is archived and is in readonly mode.
callbacks don't work from extended modules
-
Christopher J. Bottaro
I forgot to mention, this patch is for Rails 2.1.0.
-
Pratik
- Assigned user set to josh
-
Repository
- State changed from new to resolved
(from [be078ee162fcae883a5621a30929879cd783a238]) Run callbacks from object's metaclass [#575 state:resolved]
-
josh
- State changed from resolved to open
We had to revert this. Apparently it broke a ton of shit.
Maybe we don't want callbacks on the metaclass, but a set of callbacks for objects as well as classes.
Lets try a new API
module ModuleWithCallbacks def self.extended(obj) obj.before_save :module_callback end def module_callback # ... end end p = Person.new p.extend(ModuleWithCallbacks) # or also do p.before_save :module_callback def p.module_callback ... endWe could have a instance variable on the object that tracks its callbacks
-
Christopher J. Bottaro
Just out of curiosity, what did it break?
It broke our webapp because we try to serialize AR instances and it complained about not being able to serialize the object's metaclass. We just decided that we shouldn't have been serializing AR instances in the first place, heh.
-
Christopher J. Bottaro
Btw, your solution of having callback chains on classes as well as instances of classes (objects) sounds great.
-
josh
Check out the latest Memoizable stuff for reference.
http://github.com/rails/rails/tr...
I've been playing around with a pattern that works for Classes and Objects.
I don't have time to work on this right now, but I do plan to get back to in in the next coming weeks.
(BTW, I'm getting obsessed with "object-oriented"/prototype driven development)
-
josh
- State changed from open to wontfix
It looks like this is going take alot more work. If you ever decide its worth pursuing, open and new ticket for refactoring Callbacks and assign it to me.