Sha256: 431048b40a0701caaffe2d2a19363d929ea957e4e7947e584d397a95c96d4538

Contents?: true

Size: 657 Bytes

Versions: 16

Compression:

Stored size: 657 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.

    def self.encode(obj)
      MultiJson.encode(obj)
    end

    def self.decode(obj)
      MultiJson.decode(obj)
    end


  end
end

Version data entries

16 entries across 16 versions & 6 rubygems

Version Path
cifrado-0.2.1 vendor/fog/lib/fog/core/json.rb
cifrado-0.2.0 vendor/fog/lib/fog/core/json.rb
hpfog-0.0.20 lib/fog/core/json.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/core/json.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/core/json.rb
fog-1.10.1 lib/fog/core/json.rb
fog-test-me-1.10.0 lib/fog/core/json.rb
cifrado-0.1.3 vendor/fog/lib/fog/core/json.rb
fog-1.10.0 lib/fog/core/json.rb
cifrado-0.1.2 vendor/fog/lib/fog/core/json.rb
cifrado-0.1.1 vendor/fog/lib/fog/core/json.rb
cifrado-0.1 vendor/fog/lib/fog/core/json.rb
fog-1.9.0 lib/fog/core/json.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/core/json.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/core/json.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/core/json.rb