7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/rails_admin/support/core_extensions.rb', line 7
def self.symbolize_hash(obj)
case obj
when Array
obj.inject([]){|res, val|
res << case val
when Hash, Array
symbolize_hash(val)
when String
val.to_sym
else
val
end
res
}
when Hash
obj.inject({}){|res, (key, val)|
nkey = case key
when String
key.to_sym
else
key
end
nval = case val
when Hash, Array
symbolize_hash(val)
when String
val.to_sym
else
val
end
res[nkey] = nval
res
}
else
obj
end
end
|