like encode, but only calls as_json, without encoding to string
# File lib/active_support/json/encoding.rb, line 53 53: def as_json(value, use_options = true) 54: check_for_circular_references(value) do 55: use_options ? value.as_json(options_for(value)) : value.as_json 56: end 57: end
# File lib/active_support/json/encoding.rb, line 45 45: def encode(value, use_options = true) 46: check_for_circular_references(value) do 47: jsonified = use_options ? value.as_json(options_for(value)) : value.as_json 48: jsonified.encode_json(self) 49: end 50: end
# File lib/active_support/json/encoding.rb, line 68 68: def escape(string) 69: Encoding.escape(string) 70: end
# File lib/active_support/json/encoding.rb, line 59 59: def options_for(value) 60: if value.is_a?(Array) || value.is_a?(Hash) 61: # hashes and arrays need to get encoder in the options, so that they can detect circular references 62: options.merge(:encoder => self) 63: else 64: options 65: end 66: end
# File lib/active_support/json/encoding.rb, line 73 73: def check_for_circular_references(value) 74: unless @seen.add?(value.__id__) 75: raise CircularReferenceError, 'object references itself' 76: end 77: yield 78: ensure 79: @seen.delete(value.__id__) 80: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.