diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-20 23:18:05 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-20 23:18:05 +0000 |
commit | dc399b96c84bc66b7c20e92fb40e9ed00daf99c2 (patch) | |
tree | 57edd3b3d5cf446392aaecfebc5a1831e960e4c8 /activeresource/lib/active_resource/formats/json_format.rb | |
parent | bd311ce9221f1df9711c791d9abfae89e029924d (diff) | |
download | rails-dc399b96c84bc66b7c20e92fb40e9ed00daf99c2.tar.gz rails-dc399b96c84bc66b7c20e92fb40e9ed00daf99c2.tar.bz2 rails-dc399b96c84bc66b7c20e92fb40e9ed00daf99c2.zip |
Added ActiveResource.format= which defaults to :xml but can also be set to :json [DHH]. Added one-off declarations of mock behavior [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7518 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib/active_resource/formats/json_format.rb')
-rw-r--r-- | activeresource/lib/active_resource/formats/json_format.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activeresource/lib/active_resource/formats/json_format.rb b/activeresource/lib/active_resource/formats/json_format.rb new file mode 100644 index 0000000000..df0d6ca372 --- /dev/null +++ b/activeresource/lib/active_resource/formats/json_format.rb @@ -0,0 +1,23 @@ +module ActiveResource + module Formats + module JsonFormat + extend self + + def extension + "json" + end + + def mime_type + "application/json" + end + + def encode(hash) + hash.to_json + end + + def decode(json) + ActiveSupport::JSON.decode(json) + end + end + end +end
\ No newline at end of file |