class Samsara::Serializer

Public Class Methods

dump(arg) click to toggle source
# File lib/samsara/serializer.rb, line 3
def self.dump(arg)
  case arg
  when Hash
    arg.to_json
  else
    arg
  end
end
load(arg) click to toggle source
# File lib/samsara/serializer.rb, line 12
def self.load(arg)
  case arg
  when String
    load JSON.parse(arg)
  when Hash
    symbolize_keys! arg
  else
    arg
  end
end
symbolize_keys!(arg) click to toggle source
# File lib/samsara/serializer.rb, line 23
def self.symbolize_keys!(arg)
  return arg unless arg.is_a? Hash
  arg.values.each{|val| symbolize_keys! val }
  arg.symbolize_keys!
end