Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS::Callbacks: fix run_callbacks for objects with negative id #6373

Merged
merged 1 commit into from
May 18, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/callbacks.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ module ClassMethods
# This generated method plays caching role. # This generated method plays caching role.
def __define_callbacks(kind, object) #:nodoc: def __define_callbacks(kind, object) #:nodoc:
chain = object.send("_#{kind}_callbacks") chain = object.send("_#{kind}_callbacks")
name = "_run_callbacks_#{chain.object_id}" name = "_run_callbacks_#{chain.object_id.abs}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object_id potentially can be negative?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it could.

unless object.respond_to?(name, true) unless object.respond_to?(name, true)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{name}() #{chain.compile} end def #{name}() #{chain.compile} end
Expand Down