提交 da3a80dd 编写于 作者: J Jeremy Kemper

Track object ids so the objects needn't respond to ==

上级 dc2caea9
......@@ -6,8 +6,8 @@ class CircularReferenceError < StandardError
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册