This project is archived and is in readonly mode.
Per-Instance Callbacks
Reported by Tom Lea | August 7th, 2008 @ 06:13 PM | in 2.x
This patch allows callbacks to be hooked up on an individual instance.
class SomeStorage
include ActiveSupport::Callbacks
define_callbacks :before_save, :after_save
def save
run_callbacks(:before_save)
puts "- save"
run_callbacks(:after_save)
end
end
store = SomeStorage.new
store.before_save do |object|
puts "saving..."
end
store.after_save do |object|
puts "saved."
end
store.save
#
# Output:
# saving...
# - save
# saved
Comments and changes to this ticket
-
Tom Lea August 7th, 2008 @ 07:08 PM
Hmm, this clashes with the way AR callbacks work... works for none AR apps using ActiveSupport (where the patch was developed), but not so much for Rails...
Ignore the patch.
-
Jeremy Kemper August 7th, 2008 @ 07:19 PM
- State changed from new to invalid
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>