mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
f2bd2404d1
This reverts commits:66638b25d7
,3f0314dbd1
, and18ce4b7eca
. Since google-api-client was added as a dependency inafa9b025e9
, multi_json is a de facto dependency of fog, so this is a needless layer. If #1034 is still an issue, I'd be happy to ship a version of multi_json that requires rubygems >= 1.3.5.
33 lines
656 B
Ruby
33 lines
656 B
Ruby
require 'multi_json'
|
|
|
|
module Fog
|
|
module JSON
|
|
|
|
def self.sanitize(data)
|
|
case data
|
|
when Array
|
|
data.map {|datum| sanitize(datum)}
|
|
when Hash
|
|
for key, value in data
|
|
data[key] = sanitize(value)
|
|
end
|
|
when ::Time
|
|
data.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
else
|
|
data
|
|
end
|
|
end
|
|
|
|
# Do the MultiJson introspection at this level so we can define our encode/decode methods and perform
|
|
# the introspection only once rather than once per call.
|
|
|
|
def self.encode(obj)
|
|
MultiJson.encode(obj)
|
|
end
|
|
|
|
def self.decode(obj)
|
|
MultiJson.decode(obj)
|
|
end
|
|
|
|
end
|
|
end
|