panko_serializer 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/docs.yml +1 -1
- data/.github/workflows/ruby.yml +6 -3
- data/docs/docs/performance.md +6 -6
- data/docs/package-lock.json +12345 -26
- data/ext/panko_serializer/attributes_writer/attributes_writer.c +1 -1
- data/ext/panko_serializer/attributes_writer/attributes_writer.h +1 -1
- data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +1 -1
- data/lib/panko/serializer.rb +8 -2
- data/lib/panko/serializer_resolver.rb +1 -0
- data/lib/panko/version.rb +1 -1
- metadata +3 -3
@@ -48,7 +48,7 @@ void empty_write_attributes(VALUE obj, VALUE attributes, EachAttributeFunc func,
|
|
48
48
|
VALUE writer) {}
|
49
49
|
|
50
50
|
AttributesWriter create_empty_attributes_writer() {
|
51
|
-
return (AttributesWriter){.object_type =
|
51
|
+
return (AttributesWriter){.object_type = UnknownObjectType,
|
52
52
|
.write_attributes = empty_write_attributes};
|
53
53
|
}
|
54
54
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
#include "plain.h"
|
8
8
|
#include "hash.h"
|
9
9
|
|
10
|
-
enum ObjectType {
|
10
|
+
enum ObjectType { UnknownObjectType = 0, ActiveRecord = 1, Plain = 2, Hash = 3 };
|
11
11
|
|
12
12
|
typedef struct _AttributesWriter {
|
13
13
|
enum ObjectType object_type;
|
@@ -49,7 +49,7 @@ SerializationDescriptor sd_read(VALUE descriptor) {
|
|
49
49
|
}
|
50
50
|
|
51
51
|
void sd_set_writer(SerializationDescriptor sd, VALUE object) {
|
52
|
-
if (sd->attributes_writer.object_type !=
|
52
|
+
if (sd->attributes_writer.object_type != UnknownObjectType) {
|
53
53
|
return;
|
54
54
|
}
|
55
55
|
|
data/lib/panko/serializer.rb
CHANGED
@@ -75,7 +75,10 @@ module Panko
|
|
75
75
|
|
76
76
|
def has_one(name, options = {})
|
77
77
|
serializer_const = options[:serializer]
|
78
|
-
|
78
|
+
if serializer_const.kind_of?(String)
|
79
|
+
serializer_const = Panko::SerializerResolver.resolve(serializer_const, self)
|
80
|
+
end
|
81
|
+
serializer_const ||= Panko::SerializerResolver.resolve(name.to_s, self)
|
79
82
|
|
80
83
|
raise "Can't find serializer for #{self.name}.#{name} has_one relationship." if serializer_const.nil?
|
81
84
|
|
@@ -88,7 +91,10 @@ module Panko
|
|
88
91
|
|
89
92
|
def has_many(name, options = {})
|
90
93
|
serializer_const = options[:serializer] || options[:each_serializer]
|
91
|
-
|
94
|
+
if serializer_const.kind_of?(String)
|
95
|
+
serializer_const = Panko::SerializerResolver.resolve(serializer_const, self)
|
96
|
+
end
|
97
|
+
serializer_const ||= Panko::SerializerResolver.resolve(name.to_s, self)
|
92
98
|
|
93
99
|
raise "Can't find serializer for #{self.name}.#{name} has_many relationship." if serializer_const.nil?
|
94
100
|
|
data/lib/panko/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panko_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosi Attias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.1.4
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: High Performance JSON Serialization for ActiveRecord & Ruby Objects
|