fast_serializer_ruby 0.1.2 → 0.1.4
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/Gemfile +4 -2
- data/Gemfile.lock +27 -27
- data/README.md +1 -1
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/fast_serializer.gemspec +27 -26
- data/lib/fast_serializer.rb +6 -4
- data/lib/fast_serializer/configuration.rb +4 -2
- data/lib/fast_serializer/json_model/array.rb +3 -5
- data/lib/fast_serializer/json_model/attribute.rb +4 -5
- data/lib/fast_serializer/json_model/has_many_relationship.rb +2 -2
- data/lib/fast_serializer/json_model/has_one_relationship.rb +2 -2
- data/lib/fast_serializer/json_model/node.rb +2 -2
- data/lib/fast_serializer/json_model/object.rb +3 -5
- data/lib/fast_serializer/json_model/relationship.rb +3 -1
- data/lib/fast_serializer/schema.rb +24 -20
- data/lib/fast_serializer/version.rb +3 -1
- metadata +22 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2fb6eb91b6bb055330cdbc9c985ae9adcbabec5c0b03c201c5d2e131a58dbd7d
|
|
4
|
+
data.tar.gz: 3f2ecb8143d86959d6539e625aa606b101eda57c4d32ae1b38760184e5b63e6c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a895d4646f7f341411c7d52950ac9c28a34a809d5dc064ed4a9c7a26bf59527389596e3f9223a4e38aad21aba50a6b0d100e1132b2138f299c62b07ca0bdfef1
|
|
7
|
+
data.tar.gz: c8c237765f1c08cecf753483b878ecdb360fcdf03982a93270832872097389169030e22432a74f20f42b07b5e7e20b348f744235c8629921e28fd1521aab6a45
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
|
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
4
6
|
|
|
5
7
|
# Specify your gem's dependencies in fast_serializer.gemspec
|
|
6
8
|
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fast_serializer_ruby (0.1.
|
|
4
|
+
fast_serializer_ruby (0.1.4)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -39,29 +39,29 @@ GEM
|
|
|
39
39
|
activesupport
|
|
40
40
|
coderay (1.1.2)
|
|
41
41
|
concurrent-ruby (1.1.5)
|
|
42
|
-
crass (1.0.
|
|
42
|
+
crass (1.0.5)
|
|
43
43
|
diff-lcs (1.3)
|
|
44
44
|
docile (1.3.2)
|
|
45
|
-
erubi (1.
|
|
46
|
-
factory_bot (5.
|
|
45
|
+
erubi (1.9.0)
|
|
46
|
+
factory_bot (5.1.1)
|
|
47
47
|
activesupport (>= 4.2.0)
|
|
48
|
-
faker (
|
|
49
|
-
i18n (>=
|
|
48
|
+
faker (2.6.0)
|
|
49
|
+
i18n (>= 1.6, < 1.8)
|
|
50
50
|
ffi (1.11.1-java)
|
|
51
|
-
i18n (1.
|
|
51
|
+
i18n (1.7.0)
|
|
52
52
|
concurrent-ruby (~> 1.0)
|
|
53
53
|
json (2.2.0)
|
|
54
54
|
json (2.2.0-java)
|
|
55
55
|
jsonapi-renderer (0.2.2)
|
|
56
|
-
loofah (2.
|
|
56
|
+
loofah (2.3.1)
|
|
57
57
|
crass (~> 1.0.2)
|
|
58
58
|
nokogiri (>= 1.5.9)
|
|
59
59
|
method_source (0.9.2)
|
|
60
60
|
mini_portile2 (2.4.0)
|
|
61
|
-
minitest (5.
|
|
62
|
-
nokogiri (1.10.
|
|
61
|
+
minitest (5.12.2)
|
|
62
|
+
nokogiri (1.10.5)
|
|
63
63
|
mini_portile2 (~> 2.4.0)
|
|
64
|
-
nokogiri (1.10.
|
|
64
|
+
nokogiri (1.10.5-java)
|
|
65
65
|
pry (0.12.2)
|
|
66
66
|
coderay (~> 1.1.0)
|
|
67
67
|
method_source (~> 0.9.0)
|
|
@@ -75,28 +75,28 @@ GEM
|
|
|
75
75
|
rails-dom-testing (2.0.3)
|
|
76
76
|
activesupport (>= 4.2.0)
|
|
77
77
|
nokogiri (>= 1.6)
|
|
78
|
-
rails-html-sanitizer (1.0
|
|
79
|
-
loofah (~> 2.
|
|
78
|
+
rails-html-sanitizer (1.3.0)
|
|
79
|
+
loofah (~> 2.3)
|
|
80
80
|
rake (10.5.0)
|
|
81
|
-
rspec (3.
|
|
82
|
-
rspec-core (~> 3.
|
|
83
|
-
rspec-expectations (~> 3.
|
|
84
|
-
rspec-mocks (~> 3.
|
|
85
|
-
rspec-benchmark (0.5.
|
|
81
|
+
rspec (3.9.0)
|
|
82
|
+
rspec-core (~> 3.9.0)
|
|
83
|
+
rspec-expectations (~> 3.9.0)
|
|
84
|
+
rspec-mocks (~> 3.9.0)
|
|
85
|
+
rspec-benchmark (0.5.1)
|
|
86
86
|
benchmark-malloc (~> 0.1.0)
|
|
87
87
|
benchmark-perf (~> 0.5.0)
|
|
88
88
|
benchmark-trend (~> 0.3.0)
|
|
89
89
|
rspec (>= 3.0.0, < 4.0.0)
|
|
90
|
-
rspec-core (3.
|
|
91
|
-
rspec-support (~> 3.
|
|
92
|
-
rspec-expectations (3.
|
|
90
|
+
rspec-core (3.9.0)
|
|
91
|
+
rspec-support (~> 3.9.0)
|
|
92
|
+
rspec-expectations (3.9.0)
|
|
93
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
94
|
-
rspec-support (~> 3.
|
|
95
|
-
rspec-mocks (3.
|
|
94
|
+
rspec-support (~> 3.9.0)
|
|
95
|
+
rspec-mocks (3.9.0)
|
|
96
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
97
|
-
rspec-support (~> 3.
|
|
98
|
-
rspec-support (3.
|
|
99
|
-
simplecov (0.17.
|
|
97
|
+
rspec-support (~> 3.9.0)
|
|
98
|
+
rspec-support (3.9.0)
|
|
99
|
+
simplecov (0.17.1)
|
|
100
100
|
docile (~> 1.1)
|
|
101
101
|
json (>= 1.8, < 3)
|
|
102
102
|
simplecov-html (~> 0.10.0)
|
|
@@ -114,7 +114,7 @@ PLATFORMS
|
|
|
114
114
|
|
|
115
115
|
DEPENDENCIES
|
|
116
116
|
active_model_serializers (~> 0.10.0)
|
|
117
|
-
activesupport
|
|
117
|
+
activesupport (< 6)
|
|
118
118
|
factory_bot
|
|
119
119
|
faker
|
|
120
120
|
fast_serializer_ruby!
|
data/README.md
CHANGED
|
@@ -105,7 +105,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
105
105
|
|
|
106
106
|
## Contributing
|
|
107
107
|
|
|
108
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
108
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/estepnv/fast_serializer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
109
109
|
|
|
110
110
|
## License
|
|
111
111
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'fast_serializer'
|
|
5
6
|
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
|
8
9
|
|
|
9
10
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
require
|
|
11
|
+
require 'pry'
|
|
11
12
|
Pry.start
|
data/fast_serializer.gemspec
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
|
|
2
|
-
lib = File.expand_path(
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require
|
|
5
|
+
require 'fast_serializer/version'
|
|
5
6
|
|
|
6
7
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
8
|
+
spec.name = 'fast_serializer_ruby'
|
|
8
9
|
spec.version = FastSerializer::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
10
|
+
spec.authors = ['Evgeny Stepanov']
|
|
11
|
+
spec.email = ['estepnv@icloud.com']
|
|
11
12
|
|
|
12
|
-
spec.summary =
|
|
13
|
-
spec.description =
|
|
14
|
-
spec.homepage =
|
|
15
|
-
spec.license =
|
|
13
|
+
spec.summary = 'Yet another serializer gem, but fast'
|
|
14
|
+
spec.description = 'fast_serializer is a lightweight ruby objects serializer.'
|
|
15
|
+
spec.homepage = 'https://github.com/estepnv/fast_serializer'
|
|
16
|
+
spec.license = 'MIT'
|
|
16
17
|
|
|
17
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
20
|
if spec.respond_to?(:metadata)
|
|
20
|
-
spec.metadata[
|
|
21
|
-
spec.metadata[
|
|
22
|
-
spec.metadata[
|
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
22
|
+
spec.metadata['source_code_uri'] = 'https://github.com/estepnv/fast_serializer'
|
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/estepnv/fast_serializer/CHANGELOG.md'
|
|
23
24
|
else
|
|
24
|
-
raise
|
|
25
|
-
|
|
25
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
26
|
+
'public gem pushes.'
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
# Specify which files should be added to the gem when it is released.
|
|
29
30
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
30
|
-
spec.files
|
|
31
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
31
32
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{(test|spec|features|git|rspec|travis)/}) }
|
|
32
33
|
end
|
|
33
|
-
spec.bindir =
|
|
34
|
+
spec.bindir = 'exe'
|
|
34
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
35
|
-
spec.require_paths = [
|
|
36
|
+
spec.require_paths = ['lib']
|
|
36
37
|
|
|
37
|
-
spec.add_development_dependency
|
|
38
|
-
spec.add_development_dependency
|
|
39
|
-
spec.add_development_dependency
|
|
40
|
-
spec.add_development_dependency
|
|
41
|
-
spec.add_development_dependency
|
|
42
|
-
spec.add_development_dependency
|
|
43
|
-
spec.add_development_dependency
|
|
44
|
-
spec.add_development_dependency
|
|
45
|
-
spec.add_development_dependency
|
|
38
|
+
spec.add_development_dependency 'active_model_serializers', '~> 0.10.0'
|
|
39
|
+
spec.add_development_dependency 'activesupport', '<6'
|
|
40
|
+
spec.add_development_dependency 'factory_bot'
|
|
41
|
+
spec.add_development_dependency 'faker'
|
|
42
|
+
spec.add_development_dependency 'pry'
|
|
43
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
44
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
45
|
+
spec.add_development_dependency 'rspec-benchmark'
|
|
46
|
+
spec.add_development_dependency 'simplecov'
|
|
46
47
|
end
|
data/lib/fast_serializer.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require
|
|
4
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fast_serializer/version'
|
|
4
|
+
require 'fast_serializer/configuration'
|
|
5
|
+
require 'fast_serializer/json_model'
|
|
6
|
+
require 'fast_serializer/schema'
|
|
5
7
|
|
|
6
8
|
module FastSerializer
|
|
7
9
|
class Error < StandardError; end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module FastSerializer
|
|
2
4
|
class Configuration
|
|
3
5
|
attr_accessor :coder
|
|
@@ -13,7 +15,7 @@ module FastSerializer
|
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
def configure(&block)
|
|
16
|
-
block
|
|
18
|
+
block&.call(config)
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
|
-
end
|
|
21
|
+
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
module FastSerializer
|
|
4
4
|
module JsonModel
|
|
5
5
|
class Array < HasManyRelationship
|
|
6
|
-
|
|
7
|
-
def serialize(resources, params={})
|
|
6
|
+
def serialize(resources, params = {})
|
|
8
7
|
return if resources.nil?
|
|
9
8
|
|
|
10
9
|
resources.map do |resource|
|
|
@@ -12,10 +11,9 @@ module FastSerializer
|
|
|
12
11
|
end
|
|
13
12
|
end
|
|
14
13
|
|
|
15
|
-
def included?(
|
|
14
|
+
def included?(_resources, _params = {})
|
|
16
15
|
true
|
|
17
16
|
end
|
|
18
|
-
|
|
19
17
|
end
|
|
20
18
|
end
|
|
21
|
-
end
|
|
19
|
+
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
module FastSerializer
|
|
4
4
|
module JsonModel
|
|
5
5
|
class Attribute < Node
|
|
6
|
-
|
|
7
|
-
def serialize(resource, params={})
|
|
6
|
+
def serialize(resource, params = {})
|
|
8
7
|
if method.is_a?(Proc)
|
|
9
8
|
method.arity.abs == 1 ? method.call(resource) : method.call(resource, params)
|
|
10
9
|
else
|
|
@@ -14,14 +13,14 @@ module FastSerializer
|
|
|
14
13
|
|
|
15
14
|
def included?(resource, params)
|
|
16
15
|
return true if @opts[:if].nil? && @opts[:unless].nil?
|
|
16
|
+
|
|
17
17
|
cond = @opts[:if] || @opts[:unless]
|
|
18
18
|
|
|
19
19
|
res = cond.call(resource, params)
|
|
20
|
-
res = !res
|
|
20
|
+
res = !res unless @opts[:unless].nil?
|
|
21
21
|
|
|
22
22
|
res
|
|
23
23
|
end
|
|
24
|
-
|
|
25
24
|
end
|
|
26
25
|
end
|
|
27
|
-
end
|
|
26
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module FastSerializer
|
|
4
4
|
module JsonModel
|
|
5
5
|
class HasManyRelationship < Relationship
|
|
6
|
-
def serialize(resource, params={})
|
|
6
|
+
def serialize(resource, params = {})
|
|
7
7
|
collection = resource.public_send(method)
|
|
8
8
|
return if collection.nil?
|
|
9
9
|
|
|
@@ -13,4 +13,4 @@ module FastSerializer
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
end
|
|
16
|
+
end
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
module FastSerializer
|
|
4
4
|
module JsonModel
|
|
5
5
|
class HasOneRelationship < Relationship
|
|
6
|
-
def serialize(resource, params={})
|
|
6
|
+
def serialize(resource, params = {})
|
|
7
7
|
serialization_schema.serialize(resource.public_send(method), params)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
|
-
end
|
|
11
|
+
end
|
|
@@ -11,11 +11,11 @@ module FastSerializer
|
|
|
11
11
|
@opts = opts || {}
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def serialize(
|
|
14
|
+
def serialize(_resource, _params = {})
|
|
15
15
|
raise NotImplementedError
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def included?(
|
|
18
|
+
def included?(_resource, _params = {})
|
|
19
19
|
raise NotImplementedError
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -17,19 +17,17 @@ module FastSerializer
|
|
|
17
17
|
def serialize(resource, params = {})
|
|
18
18
|
return if resource.nil?
|
|
19
19
|
|
|
20
|
-
attributes.values.
|
|
20
|
+
attributes.values.each_with_object({}) do |attribute, res|
|
|
21
21
|
next res unless attribute.included?(resource, params)
|
|
22
22
|
|
|
23
23
|
val = attribute.serialize(resource, params)
|
|
24
24
|
res[attribute.key] = val if val
|
|
25
|
-
res
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
|
-
def included?(
|
|
28
|
+
def included?(_resource, _params = {})
|
|
30
29
|
true
|
|
31
30
|
end
|
|
32
|
-
|
|
33
31
|
end
|
|
34
32
|
end
|
|
35
|
-
end
|
|
33
|
+
end
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module FastSerializer
|
|
4
|
-
|
|
5
4
|
class Schema
|
|
6
|
-
|
|
7
5
|
module InheritanceSupport
|
|
8
|
-
|
|
9
6
|
def inherited(subclass)
|
|
10
|
-
subclass.
|
|
11
|
-
subclass.instance_variable_set(:@_root, _root)
|
|
12
|
-
end
|
|
7
|
+
subclass._serialization_schema ||= JsonModel::Object.new
|
|
13
8
|
|
|
9
|
+
_serialization_schema.attributes.each do |key, attribute|
|
|
10
|
+
subclass._serialization_schema.attributes[key] = attribute
|
|
11
|
+
end
|
|
12
|
+
end
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
module SchemaInterface
|
|
16
|
+
attr_accessor :_root, :_serialization_schema
|
|
17
17
|
|
|
18
|
-
def
|
|
18
|
+
def init
|
|
19
|
+
@_root ||= nil
|
|
19
20
|
@_serialization_schema ||= JsonModel::Object.new
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
attr_accessor :_root
|
|
23
|
-
|
|
24
23
|
# @param [Array] attribute_names
|
|
25
24
|
def attributes(*attribute_names)
|
|
26
25
|
attribute_names.each do |attribute_name|
|
|
@@ -45,7 +44,9 @@ module FastSerializer
|
|
|
45
44
|
# @param [String] attribute_name
|
|
46
45
|
# @param [Hash] opts - attribute options
|
|
47
46
|
def has_one(attribute_name, opts = {})
|
|
48
|
-
|
|
47
|
+
unless opts[:serializer]
|
|
48
|
+
raise ArgumentError, 'Serializer is not provided'
|
|
49
|
+
end
|
|
49
50
|
|
|
50
51
|
serialization_schema = opts.delete(:serializer)._serialization_schema
|
|
51
52
|
_serialization_schema.add_attribute JsonModel::HasOneRelationship.new(
|
|
@@ -56,12 +57,14 @@ module FastSerializer
|
|
|
56
57
|
)
|
|
57
58
|
end
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
alias belongs_to has_one
|
|
60
61
|
|
|
61
62
|
# @param [String] attribute_name
|
|
62
63
|
# @param [Hash] opts - attribute options
|
|
63
64
|
def has_many(attribute_name, opts = {})
|
|
64
|
-
|
|
65
|
+
unless opts[:serializer]
|
|
66
|
+
raise ArgumentError, 'Serializer is not provided'
|
|
67
|
+
end
|
|
65
68
|
|
|
66
69
|
serialization_schema = opts.delete(:serializer)._serialization_schema
|
|
67
70
|
_serialization_schema.add_attribute JsonModel::HasManyRelationship.new(
|
|
@@ -75,7 +78,9 @@ module FastSerializer
|
|
|
75
78
|
# @param [String] attribute_name
|
|
76
79
|
# @param [Hash] opts - attribute options
|
|
77
80
|
def list(attribute_name, opts = {})
|
|
78
|
-
|
|
81
|
+
unless opts[:serializer]
|
|
82
|
+
raise ArgumentError, 'Serializer is not provided'
|
|
83
|
+
end
|
|
79
84
|
|
|
80
85
|
serialization_schema = opts.delete(:serializer)._serialization_schema
|
|
81
86
|
_serialization_schema.add_attribute JsonModel::Array.new(
|
|
@@ -96,6 +101,7 @@ module FastSerializer
|
|
|
96
101
|
attr_accessor :resource, :params
|
|
97
102
|
|
|
98
103
|
def initialize(resource, params = {})
|
|
104
|
+
init if respond_to?(:init)
|
|
99
105
|
@resource = resource
|
|
100
106
|
@params = (params || {}).symbolize_keys
|
|
101
107
|
@params[:self] = self
|
|
@@ -115,13 +121,9 @@ module FastSerializer
|
|
|
115
121
|
|
|
116
122
|
root = (_root || params.delete(:root))
|
|
117
123
|
|
|
118
|
-
if root && root.
|
|
119
|
-
res = { root => res }
|
|
120
|
-
end
|
|
124
|
+
res = { root => res } if root && !root.empty?
|
|
121
125
|
|
|
122
|
-
if res.is_a?(Hash) && meta
|
|
123
|
-
res[:meta] = meta
|
|
124
|
-
end
|
|
126
|
+
res[:meta] = meta if res.is_a?(Hash) && meta
|
|
125
127
|
|
|
126
128
|
res
|
|
127
129
|
end
|
|
@@ -159,7 +161,9 @@ module FastSerializer
|
|
|
159
161
|
base.include Serialization
|
|
160
162
|
base.extend InheritanceSupport
|
|
161
163
|
base.extend SchemaInterface
|
|
164
|
+
|
|
165
|
+
base.init
|
|
162
166
|
end
|
|
163
167
|
end
|
|
164
168
|
end
|
|
165
|
-
end
|
|
169
|
+
end
|
metadata
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fast_serializer_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evgeny Stepanov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: active_model_serializers
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.10.0
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 0.10.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '6'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - "<"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '6'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: factory_bot
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
@@ -53,7 +53,7 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: faker
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
@@ -81,35 +81,35 @@ dependencies:
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rake
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- - "
|
|
87
|
+
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
89
|
+
version: '10.0'
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- - "
|
|
94
|
+
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
96
|
+
version: '10.0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
98
|
+
name: rspec
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version:
|
|
103
|
+
version: '3.0'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
110
|
+
version: '3.0'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
112
|
+
name: rspec-benchmark
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - ">="
|
|
@@ -123,7 +123,7 @@ dependencies:
|
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '0'
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name:
|
|
126
|
+
name: simplecov
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - ">="
|