userializer 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +18 -0
- data/Gemfile.lock +2 -2
- data/lib/userializer/has_many.rb +9 -2
- data/lib/userializer/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff7b3083a1f53deccff3139fc8625c9ac17a313f07fd2f0b98ca912a8ef6d46
|
4
|
+
data.tar.gz: cf90d14d354b5dbcbd6bb1e9021860583b57adf2ff10bc599a8aa15e3c33531d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 140ffbbe09cd46455c97fcc5e9d36b6adb9f7cca28b21b0c4231f316d887125fd131b0e8046e49c3bea1c1a6719ba3e99c8bb143d5e2d127a5e7ef6843e659c2
|
7
|
+
data.tar.gz: fc5b3c983c81bedd8807c38a41a0bf323ad5597eaacbfa4c64a618744c092bf9e252f6129dc88fb0c5c2c5f1715bee6271b6e8cbf21f86eb0d8889ca53624aed
|
@@ -0,0 +1,18 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
run_tests:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.4.1
|
6
|
+
|
7
|
+
working_directory: ~/userializer
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
- run: bundle install --path=vendor/bundle
|
12
|
+
- run: bundle exec rspec --color --require spec_helper --format progress spec
|
13
|
+
|
14
|
+
workflows:
|
15
|
+
version: 2
|
16
|
+
test:
|
17
|
+
jobs:
|
18
|
+
- run_tests
|
data/Gemfile.lock
CHANGED
data/lib/userializer/has_many.rb
CHANGED
@@ -15,17 +15,24 @@ module USerializer
|
|
15
15
|
def merge_attributes(res, ser, opts)
|
16
16
|
return unless @conditional_block.call(ser.object, opts)
|
17
17
|
|
18
|
-
res[@id_key] = (ser
|
18
|
+
res[@id_key] = (entities(ser) || []).compact.map do |obj|
|
19
19
|
obj.nil? ? nil : obj.send(@embed_key)
|
20
20
|
end.compact
|
21
21
|
end
|
22
22
|
|
23
23
|
def merge_root(res, ser, opts)
|
24
|
-
objs = ser
|
24
|
+
objs = entities(ser) || []
|
25
25
|
|
26
26
|
return if objs.empty? || !@conditional_block.call(ser.object, opts)
|
27
27
|
|
28
28
|
ArraySerializer.new(objs, @opts).merge_root(res, opts)
|
29
29
|
end
|
30
|
+
|
31
|
+
def entities(ser)
|
32
|
+
obj = ser.send(@key) || []
|
33
|
+
return obj unless @opts[:scope]
|
34
|
+
|
35
|
+
obj.send(@opts[:scope])
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
data/lib/userializer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Montagne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,6 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".circleci/config.yml"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".rspec"
|
92
93
|
- ".travis.yml"
|
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
126
|
rubyforge_project:
|
126
|
-
rubygems_version:
|
127
|
+
rubygems_version: 3.0.0.beta3
|
127
128
|
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: Write a short summary, because RubyGems requires one.
|