forest_liana 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c12d6ca66245644504b33629b1fed37aa2f490a
|
4
|
+
data.tar.gz: 474f0b4140dd86509ad7709e99cd7888cb2182ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1105cd520ac6d0feba4672c163900ca91f05214bef34a1373ee0fb84404ba1a038f358397d817b763816d4707cc99916a7a7cd271b18537ba4965aa09edb3f9
|
7
|
+
data.tar.gz: dca34559ad4e126ecd21167d4ca55712f12615742d1df42dd41263941209bce1f848698ce230d88ca43b62f4fb3194d3272c874358ad332b64bf6fb3de06cfb3
|
@@ -10,14 +10,15 @@ module ForestLiana
|
|
10
10
|
|
11
11
|
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
12
12
|
|
13
|
-
|
14
13
|
def forest_user
|
15
14
|
@jwt_decoded_token
|
16
15
|
end
|
17
16
|
|
18
17
|
def serialize_model(model, options = {})
|
19
18
|
options[:is_collection] = false
|
20
|
-
JSONAPI::Serializer.serialize(model, options)
|
19
|
+
json = JSONAPI::Serializer.serialize(model, options)
|
20
|
+
|
21
|
+
force_utf8_encoding(json)
|
21
22
|
end
|
22
23
|
|
23
24
|
def serialize_models(models, options = {})
|
@@ -34,7 +35,7 @@ module ForestLiana
|
|
34
35
|
json[:meta][:has_more] = options[:has_more]
|
35
36
|
end
|
36
37
|
|
37
|
-
json
|
38
|
+
force_utf8_encoding(json)
|
38
39
|
end
|
39
40
|
|
40
41
|
def authenticate_user_from_jwt
|
@@ -53,5 +54,36 @@ module ForestLiana
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
private
|
58
|
+
|
59
|
+
def force_utf8_encoding(json)
|
60
|
+
if json['data'].class == Array
|
61
|
+
# NOTICE: Collection of records case
|
62
|
+
json['data'].each { |record| force_utf8_attributes_encoding(record) }
|
63
|
+
else
|
64
|
+
# NOTICE: Single record case
|
65
|
+
force_utf8_attributes_encoding(json['data'])
|
66
|
+
end
|
67
|
+
|
68
|
+
json['included'].each do |association|
|
69
|
+
force_utf8_attributes_encoding(association)
|
70
|
+
end
|
71
|
+
|
72
|
+
json
|
73
|
+
end
|
74
|
+
|
75
|
+
def force_utf8_attributes_encoding(model)
|
76
|
+
# NOTICE: Declare all strings are encoded in utf-8
|
77
|
+
model['attributes'].each do |name, value|
|
78
|
+
if value.respond_to?(:force_encoding)
|
79
|
+
begin
|
80
|
+
model['attributes'][name] = value.force_encoding('utf-8')
|
81
|
+
rescue
|
82
|
+
# NOTICE: Enums are frozen Strings
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
56
88
|
end
|
57
89
|
end
|
data/lib/forest_liana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|