Module: Rpush::MultiJsonHelper

Instance Method Summary collapse

Instance Method Details

#multi_json_dump(string, options = {}) ⇒ Object



12
13
14
# File 'lib/rpush/multi_json_helper.rb', line 12

def multi_json_dump(string, options = {})
  MultiJson.respond_to?(:dump) ? MultiJson.dump(string, options) : MultiJson.encode(string, options)
end

#multi_json_load(string, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/rpush/multi_json_helper.rb', line 3

def multi_json_load(string, options = {})
  # Calling load on multi_json less than v1.3.0 attempts to load a file from disk.
  if Gem.loaded_specs['multi_json'].version >= Gem::Version.create('1.3.0')
    MultiJson.load(string, options)
  else
    MultiJson.decode(string, options)
  end
end