From 00ee990443189649e481b2c30945e7a1029d8280 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 5 Jun 2009 18:25:07 -0700 Subject: JSON: split encoding and coercion --- activeresource/lib/active_resource/base.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'activeresource/lib/active_resource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 11a7bbba3e..dbc418bef3 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -873,7 +873,7 @@ module ActiveResource attributes.to_xml({:root => self.class.element_name}.merge(options)) end - # Converts the resource to a JSON string representation. + # Coerces to a hash for JSON encoding. # # ==== Options # The +options+ are passed to the +to_json+ method on each @@ -897,8 +897,8 @@ module ActiveResource # # person.to_json(:except => ["first_name"]) # # => {"last_name": "Smith"} - def to_json(options={}) - ActiveSupport::JSON.encode(attributes, options) + def as_json(options = nil) + attributes.as_json(options) end # Returns the serialized string representation of the resource in the configured @@ -1072,11 +1072,6 @@ module ActiveResource self.class.__send__(:split_options, options) end - # For compatibility with ActiveSupport::JSON.encode - def rails_to_json(options, *args) - to_json(options) - end - def method_missing(method_symbol, *arguments) #:nodoc: method_name = method_symbol.to_s -- cgit v1.2.3