forest_liana 2.15.5 → 2.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/serializers/forest_liana/serializer_factory.rb +42 -13
- data/lib/forest_liana/version.rb +1 -1
- data/spec/dummy/log/test.log +1270 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d28cb764abdf11b248c2f0c4854309ec86e4288
|
4
|
+
data.tar.gz: 0f5fc89f1d186b41d4de200f3b5f81dc06cde144
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1ab6fa36640e97f8cc6ed04e657b571f7b6841763e155d4c389ea92f44f9d2d4489b2f4479d49362edf09b1329cdeb101da912a5f917521b344ce7f79cfb1b6
|
7
|
+
data.tar.gz: da96429efbc9b5b1b9c295f36f9cb05264f2c9176ef659ffdddd9247ba0b9e65d61b15158580297f27ca9c3ab2c8dd84f23c131bc5f81e1886cae177658870df
|
@@ -179,17 +179,27 @@ module ForestLiana
|
|
179
179
|
|
180
180
|
unless @is_smart_collection
|
181
181
|
attributes(active_record_class).each do |attribute|
|
182
|
-
serializer.attribute(attribute)
|
182
|
+
serializer.attribute(attribute) do |x|
|
183
|
+
begin
|
184
|
+
object.send(attribute)
|
185
|
+
rescue
|
186
|
+
nil
|
187
|
+
end
|
188
|
+
end
|
183
189
|
end
|
184
190
|
|
185
191
|
# NOTICE: Format time type fields during the serialization.
|
186
192
|
attributes_time(active_record_class).each do |attribute|
|
187
193
|
serializer.attribute(attribute) do |x|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
194
|
+
begin
|
195
|
+
value = object.send(attribute)
|
196
|
+
if value
|
197
|
+
match = /(\d{2}:\d{2}:\d{2})/.match(value.to_s)
|
198
|
+
(match && match[1]) ? match[1] : nil
|
199
|
+
else
|
200
|
+
nil
|
201
|
+
end
|
202
|
+
rescue
|
193
203
|
nil
|
194
204
|
end
|
195
205
|
end
|
@@ -198,22 +208,38 @@ module ForestLiana
|
|
198
208
|
# NOTICE: Format serialized fields.
|
199
209
|
attributes_serialized(active_record_class).each do |attr, serialization|
|
200
210
|
serializer.attribute(attr) do |x|
|
201
|
-
|
202
|
-
|
211
|
+
begin
|
212
|
+
value = object.send(attr)
|
213
|
+
value ? value.to_json : nil
|
214
|
+
rescue
|
215
|
+
nil
|
216
|
+
end
|
203
217
|
end
|
204
218
|
end
|
205
219
|
|
206
220
|
# NOTICE: Format CarrierWave url attribute
|
207
221
|
if active_record_class.respond_to?(:mount_uploader)
|
208
222
|
active_record_class.uploaders.each do |key, value|
|
209
|
-
serializer.attribute(key)
|
223
|
+
serializer.attribute(key) do |x|
|
224
|
+
begin
|
225
|
+
object.send(key).try(:url)
|
226
|
+
rescue
|
227
|
+
nil
|
228
|
+
end
|
229
|
+
end
|
210
230
|
end
|
211
231
|
end
|
212
232
|
|
213
233
|
# NOTICE: Format Paperclip url attribute
|
214
234
|
if active_record_class.respond_to?(:attachment_definitions)
|
215
235
|
active_record_class.attachment_definitions.each do |key, value|
|
216
|
-
serializer.attribute(key)
|
236
|
+
serializer.attribute(key) do |x|
|
237
|
+
begin
|
238
|
+
object.send(key)
|
239
|
+
rescue
|
240
|
+
nil
|
241
|
+
end
|
242
|
+
end
|
217
243
|
end
|
218
244
|
end
|
219
245
|
|
@@ -223,7 +249,11 @@ module ForestLiana
|
|
223
249
|
active_record_class.acts_as_taggable.respond_to?(:to_a)
|
224
250
|
active_record_class.acts_as_taggable.to_a.each do |key, value|
|
225
251
|
serializer.attribute(key) do |x|
|
226
|
-
|
252
|
+
begin
|
253
|
+
object.send(key).map(&:name)
|
254
|
+
rescue
|
255
|
+
nil
|
256
|
+
end
|
227
257
|
end
|
228
258
|
end
|
229
259
|
end
|
@@ -277,8 +307,7 @@ module ForestLiana
|
|
277
307
|
serializer.send(:has_many, :mixpanel_last_events) { }
|
278
308
|
end
|
279
309
|
|
280
|
-
ForestLiana::SerializerFactory.define_serializer(active_record_class,
|
281
|
-
serializer)
|
310
|
+
ForestLiana::SerializerFactory.define_serializer(active_record_class, serializer)
|
282
311
|
|
283
312
|
serializer
|
284
313
|
end
|
data/lib/forest_liana/version.rb
CHANGED