light_serializer 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +2 -0
- data/Gemfile.lock +4 -4
- data/bench.rb +3 -0
- data/lib/light_serializer/hashed_object.rb +2 -1
- data/lib/light_serializer/helpers/with_custom_root.rb +2 -1
- data/lib/light_serializer/serialize_collection.rb +5 -1
- data/lib/light_serializer/serializer.rb +1 -0
- data/lib/light_serializer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e19a7ae11ca3bfee4350cad7874ba08e2f07a01031886c51585dda15538b9963
|
4
|
+
data.tar.gz: 38e370df48a4f0ec77b627038320f045425a761c2dceb3021a032eadd387a402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 172a24e89701dbb0d0784ef48aed9e3565f11184abdf8f70bfa0a0bbdf605df822593bf7da179995988159fb42d53ba3ae431c0deea071add5b675edfd843962
|
7
|
+
data.tar.gz: f5c0dc2b82b75a95a547061d59e3682eb96828704a252a1f844c25b5ca3a29cc12de99f7e63621bef67e2d04fb91b2bf81c622cc85bbd54505193036bfd3c0a9
|
data/.reek.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
light_serializer (0.0.
|
4
|
+
light_serializer (0.0.8)
|
5
5
|
oj (~> 3)
|
6
6
|
|
7
7
|
GEM
|
@@ -37,9 +37,9 @@ GEM
|
|
37
37
|
kwalify (0.7.2)
|
38
38
|
method_source (0.9.0)
|
39
39
|
minitest (5.11.3)
|
40
|
-
oj (3.7.
|
40
|
+
oj (3.7.4)
|
41
41
|
parallel (1.12.1)
|
42
|
-
parser (2.5.
|
42
|
+
parser (2.5.3.0)
|
43
43
|
ast (~> 2.4.0)
|
44
44
|
powerpack (0.1.2)
|
45
45
|
pry (0.11.3)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
pry (~> 0.10)
|
51
51
|
rainbow (3.0.0)
|
52
52
|
rake (10.5.0)
|
53
|
-
reek (5.
|
53
|
+
reek (5.2.0)
|
54
54
|
codeclimate-engine-rb (~> 0.4.0)
|
55
55
|
kwalify (~> 0.7.0)
|
56
56
|
parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
|
data/bench.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
2
4
|
require 'bundler/inline'
|
3
5
|
|
@@ -297,3 +299,4 @@ benchmark_collection(ams_arg: '(without logging)', oj_arg: '(with Oj)')
|
|
297
299
|
# Associations
|
298
300
|
benchmark_associations_instance
|
299
301
|
benchmark_associations_collection
|
302
|
+
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength
|
@@ -54,7 +54,7 @@ module LightSerializer
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def active_record_relation?(object)
|
57
|
-
|
57
|
+
defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation)
|
58
58
|
end
|
59
59
|
|
60
60
|
def hashed_entity(entity, nested_serializer)
|
@@ -71,6 +71,7 @@ module LightSerializer
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
# :reek:ManualDispatch
|
74
75
|
def obtain_value(object, attribute)
|
75
76
|
if serializer.respond_to?(attribute)
|
76
77
|
serializer.public_send(attribute)
|
@@ -14,7 +14,7 @@ module LightSerializer
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_json
|
17
|
-
|
17
|
+
Oj.dump(collection_with_root, mode: :compat)
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_hash
|
@@ -23,6 +23,10 @@ module LightSerializer
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
def collection_with_root
|
27
|
+
with_custom_root(root) { hashed_collection }
|
28
|
+
end
|
29
|
+
|
26
30
|
def hashed_collection
|
27
31
|
collection.map { |entity| serializer.new(entity, context: context).to_hash }
|
28
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Rodionov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oj
|