promethee 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/promethee/_edit.html.erb +1 -1
- data/lib/promethee/data.rb +21 -2
- data/lib/promethee/rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff47d2fab2501f64ec51b21f530d35a1132d1819
|
4
|
+
data.tar.gz: 3ec913a94a54255692cab5058afe015c5d3dd5d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d372fe3fd96e76820fb167ddd1927ea91773162cde7abf3606db752eabbfcdae4a56ecfcf476a268a77752b6ca1464abd4c400479b83121ddf18f676c800b787
|
7
|
+
data.tar.gz: cdb2fdd8b69026dfb5673108f2a659e2a866b9f1efff49438bd4b04493f6787f0cdfe354082614d5181e505d8d7520d0bffcacbc74b55dcbf2f9924e3f54ac7c
|
data/lib/promethee/data.rb
CHANGED
@@ -30,8 +30,27 @@ module Promethee
|
|
30
30
|
|
31
31
|
protected
|
32
32
|
|
33
|
-
def convert_if_necessary(
|
34
|
-
|
33
|
+
def convert_if_necessary(string_or_hash_or_anything)
|
34
|
+
# string_or_hash_or_anything could be a string a hash or anything so we need to handle potential exception to keep this method safe
|
35
|
+
begin
|
36
|
+
converted = string_or_hash_or_anything.is_a?(String) ? JSON.parse(string_or_hash_or_anything, symbolize_names: true) : string_or_hash_or_anything
|
37
|
+
rescue
|
38
|
+
converted = {}
|
39
|
+
end
|
40
|
+
|
41
|
+
# The parsed json could be anything: "\"hey\"" => "hey", "[\"hey\"]" => ["hey"], "null" => nil, ...
|
42
|
+
converted = {} unless converted.is_a? Hash
|
43
|
+
|
44
|
+
# The data might not be a json string so the "symbolize_names" options wouldn't do anything on a ruby hash because JSON.parse wouldn't be called
|
45
|
+
converted.deep_symbolize_keys!
|
46
|
+
|
47
|
+
# The children array is required in order to make this class work
|
48
|
+
converted[:children] = [] unless converted[:children].is_a?(Array)
|
49
|
+
|
50
|
+
# The type is required in order to make this class work
|
51
|
+
converted[:type] = converted[:type].is_a?(String) || converted[:type].is_a?(Symbol) ? converted[:type].to_s : 'page'
|
52
|
+
|
53
|
+
converted
|
35
54
|
end
|
36
55
|
|
37
56
|
def deep_clone(hash)
|