aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-06-05 18:25:07 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-06-08 13:21:30 -0700
commit00ee990443189649e481b2c30945e7a1029d8280 (patch)
treec30e731055da3a6f67ea4c154059ff7245ef6e1c /activeresource
parent5e1b46d4c285124737abe2e08dec97e4af1f4be7 (diff)
downloadrails-00ee990443189649e481b2c30945e7a1029d8280.tar.gz
rails-00ee990443189649e481b2c30945e7a1029d8280.tar.bz2
rails-00ee990443189649e481b2c30945e7a1029d8280.zip
JSON: split encoding and coercion
Diffstat (limited to 'activeresource')
-rw-r--r--activeresource/lib/active_resource/base.rb11
1 files changed, 3 insertions, 8 deletions
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