Sha256: abd57f4264f247f419fd7d8afc289263da0123fe85fe85fd14beb4ab19b84ea9

Contents?: true

Size: 905 Bytes

Versions: 13

Compression:

Stored size: 905 Bytes

Contents

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.

    if MultiJson.respond_to?(:dump)
      def self.encode(obj)
        MultiJson.dump(obj)
      end
    else
      def self.encode(obj)
        MultiJson.encode(obj)
      end
    end

    if MultiJson.respond_to?(:load)
      def self.decode(obj)
        MultiJson.load(obj)
      end
    else
      def self.decode(obj)
        MultiJson.decode(obj)
      end
    end


  end
end

Version data entries

13 entries across 13 versions & 7 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/core/json.rb
fog-nirvanix-1.8.1 lib/fog/core/json.rb
fog-parser-fix-1.6.1 lib/fog/core/json.rb
fog-test-again-1.6.0 lib/fog/core/json.rb
fog-parser-fix-1.6.0 lib/fog/core/json.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/core/json.rb
fog-sgonyea-1.8.1 lib/fog/core/json.rb
fog-1.8.0 lib/fog/core/json.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/core/json.rb
fog-1.7.0 lib/fog/core/json.rb
fog-1.6.0 lib/fog/core/json.rb
fog-1.5.0 lib/fog/core/json.rb
fog-1.4.0 lib/fog/core/json.rb