surrealist 1.3.0 → 1.3.1
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/.travis.yml +0 -1
- data/CHANGELOG.md +6 -0
- data/lib/surrealist/serializer.rb +20 -0
- data/lib/surrealist/value_assigner.rb +5 -2
- data/lib/surrealist/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: 5067bf220ce8d757b29dc527c562e28410070dc101396d3029f3442940ebcebf
|
4
|
+
data.tar.gz: '09513dc82a8d7538fb9a5e77c842a596a27c5f2ba201960b396607373dbc029a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6db73c57dae2758e58701201fa9835b6c5c177df66b94f6e81688ad5f5c8e06e914c14b8cb97336678d68353303ca5d3f5eb572a25b6d2c9ab6cd8310fb7a699
|
7
|
+
data.tar.gz: 450fee40e105f4a88213ef30147a2e67d249455d82a6383183ab9dca4eb8252ac857f6eaec37ccfe72f5c525ce88c9fb272160855ca01d6a91883b9a0d8b9a42
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 1.3.1
|
2
|
+
|
3
|
+
## Fixed
|
4
|
+
* Invoke parent serializer method instead of object method with the same names ([@kolasss][]) [#118](https://github.com/nesaulov/surrealist/pull/118)
|
5
|
+
|
1
6
|
# 1.3.0
|
2
7
|
|
3
8
|
## Added
|
@@ -115,3 +120,4 @@
|
|
115
120
|
[@past-one]: https://github.com/past-one
|
116
121
|
[@stefkin]: https://github.com/stefkin
|
117
122
|
[@gjhenrique]: https://github.com/gjhenrique
|
123
|
+
[@kolasss]: https://github.com/kolasss
|
@@ -48,6 +48,26 @@ module Surrealist
|
|
48
48
|
|
49
49
|
# Plural form ¯\_(ツ)_/¯
|
50
50
|
alias serializer_contexts serializer_context
|
51
|
+
|
52
|
+
# Only lookup for methods defined in Surrealist::Serializer subclasses
|
53
|
+
# to prevent invoke of Kernel methods
|
54
|
+
#
|
55
|
+
# @param [Symbol] method method to be invoked
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
def method_defined?(method)
|
59
|
+
return true if instance_methods(false).include?(method)
|
60
|
+
return false if superclass == Surrealist::Serializer
|
61
|
+
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
def private_method_defined?(method)
|
66
|
+
return true if private_instance_methods(false).include?(method)
|
67
|
+
return false if superclass == Surrealist::Serializer
|
68
|
+
|
69
|
+
super
|
70
|
+
end
|
51
71
|
end
|
52
72
|
|
53
73
|
# NOTE: #context will work only when using serializer explicitly,
|
@@ -47,8 +47,8 @@ module Surrealist
|
|
47
47
|
# @return [Object] the return value of the method
|
48
48
|
def invoke_method(instance, method)
|
49
49
|
object = instance.instance_variable_get(:@object)
|
50
|
-
instance_method = instance.class.
|
51
|
-
|
50
|
+
instance_method = instance.class.method_defined?(method) ||
|
51
|
+
instance.class.private_method_defined?(method)
|
52
52
|
invoke_object = !instance_method && object && object.respond_to?(method, true)
|
53
53
|
invoke_object ? object.send(method) : instance.send(method)
|
54
54
|
end
|
@@ -77,6 +77,7 @@ module Surrealist
|
|
77
77
|
# @return [Array] of schemas
|
78
78
|
def assign_nested_collection(instance, value)
|
79
79
|
return if @skip_set.include?(value.first.class)
|
80
|
+
|
80
81
|
with_skip_set(instance.class) { Surrealist.surrealize_collection(value, raw: true) }
|
81
82
|
end
|
82
83
|
|
@@ -88,6 +89,7 @@ module Surrealist
|
|
88
89
|
# @return [Hash] schema
|
89
90
|
def assign_nested_record(instance, value)
|
90
91
|
return if @skip_set.include?(value.class)
|
92
|
+
|
91
93
|
with_skip_set(instance.class) { value.build_schema }
|
92
94
|
end
|
93
95
|
|
@@ -98,6 +100,7 @@ module Surrealist
|
|
98
100
|
# @return [Object] block result
|
99
101
|
def with_skip_set(klass)
|
100
102
|
return yield if @skip_set.include?(klass)
|
103
|
+
|
101
104
|
@skip_set.add(klass)
|
102
105
|
result = yield
|
103
106
|
@skip_set.delete(klass)
|
data/lib/surrealist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surrealist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Esaulov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|