mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Track object ids so the objects needn't respond to ==
This commit is contained in:
@@ -6,8 +6,8 @@ module ActiveSupport
|
||||
# Converts a Ruby object into a JSON string.
|
||||
def self.encode(value, options = {})
|
||||
seen = (options[:seen] ||= [])
|
||||
raise CircularReferenceError, 'object references itself' if seen.include?(value)
|
||||
seen << value
|
||||
raise CircularReferenceError, 'object references itself' if seen.include?(value.object_id)
|
||||
seen << value.object_id
|
||||
value.send(:rails_to_json, options)
|
||||
ensure
|
||||
seen.pop
|
||||
|
||||
Reference in New Issue
Block a user