Module: Captivus::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/captivus/util.rb

Instance Method Summary collapse

Instance Method Details

#hash_to_json(hash) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/captivus/util.rb', line 8

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

#json_to_hash(json) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/captivus/util.rb', line 16

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