2007-12-21 08:48:59 +01:00
|
|
|
module ActiveResource
|
|
|
|
module Formats
|
|
|
|
module JsonFormat
|
|
|
|
extend self
|
2008-09-07 07:54:05 +02:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def extension
|
|
|
|
"json"
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def mime_type
|
|
|
|
"application/json"
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
|
|
|
|
def encode(hash, options={})
|
2007-12-21 08:48:59 +01:00
|
|
|
hash.to_json
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def decode(json)
|
|
|
|
ActiveSupport::JSON.decode(json)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2008-09-07 07:54:05 +02:00
|
|
|
end
|