Sha256: 6428b250f073b19c9b3cf1f8f733dece8bfbb4c48e9a6ffecbeca5d3bda95661

Contents?: true

Size: 402 Bytes

Versions: 2

Compression:

Stored size: 402 Bytes

Contents

require 'multi_json'

# TODO: test
module Captivus
  module Util
    extend self

    def hash_to_json(hash)
      if MultiJson.respond_to?(:adapter)
        MultiJson.dump hash
      else
        MultiJson.encode hash
      end
    end

    def json_to_hash(json)
      if MultiJson.respond_to?(:adapter)
        MultiJson.load json
      else
        MultiJson.decode json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
captivus-0.0.6 lib/captivus/util.rb
captivus-0.0.5 lib/captivus/util.rb