graphiti 1.0.alpha.10 → 1.0.alpha.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphiti/serializer.rb +10 -0
- data/lib/graphiti/util/serializer_attributes.rb +16 -3
- data/lib/graphiti/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b451b3a2214bfee53214b84b53455b40df0a555
|
4
|
+
data.tar.gz: f3208a80a842591303a7f091f6544edb1c26ac3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877bbfdfc4af3bd92c6ff59bc932d5dc1022a9fee8ed2d138da4045cd01c7c5249e2ef06c993e83084fce6c5fa89f7f54ae6a05ca778750d4eb95e7ff01ee887
|
7
|
+
data.tar.gz: 075a9538fd31ecc16c84a317d3d80445d447de5598eb4bd23afa493c482845789fe33b66af0b4c699c976e513e1f9bd721096d7b0b7018303d6b56fa1d9420a4
|
data/lib/graphiti/serializer.rb
CHANGED
@@ -5,6 +5,16 @@ module Graphiti
|
|
5
5
|
include Graphiti::SerializableHash
|
6
6
|
prepend Graphiti::SerializableTempId
|
7
7
|
|
8
|
+
# Keep track of what attributes have been applied by the Resource,
|
9
|
+
# via .attribute, and which have been applied by a custom serializer
|
10
|
+
# class/file.
|
11
|
+
# This way, we can ensure attributes NOT applied by a resource still
|
12
|
+
# go through type checking/coercion
|
13
|
+
class_attribute :attributes_applied_via_resource
|
14
|
+
class_attribute :extra_attributes_applied_via_resource
|
15
|
+
self.attributes_applied_via_resource = []
|
16
|
+
self.extra_attributes_applied_via_resource = []
|
17
|
+
|
8
18
|
def self.inherited(klass)
|
9
19
|
super
|
10
20
|
klass.class_eval do
|
@@ -20,15 +20,28 @@ module Graphiti
|
|
20
20
|
if @serializer.attribute_blocks[@name].nil?
|
21
21
|
@serializer.send(_method, @name, serializer_options, &proc)
|
22
22
|
else
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
unless @serializer.send(applied_method).include?(@name)
|
24
|
+
inner = @serializer.attribute_blocks.delete(@name)
|
25
|
+
wrapped = wrap_proc(inner)
|
26
|
+
@serializer.send(_method, @name, serializer_options, &wrapped)
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
30
|
+
|
31
|
+
existing = @serializer.send(applied_method)
|
32
|
+
@serializer.send(:"#{applied_method}=", [@name] | existing)
|
28
33
|
end
|
29
34
|
|
30
35
|
private
|
31
36
|
|
37
|
+
def applied_method
|
38
|
+
if extra?
|
39
|
+
:extra_attributes_applied_via_resource
|
40
|
+
else
|
41
|
+
:attributes_applied_via_resource
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
def _method
|
33
46
|
extra? ? :extra_attribute : :attribute
|
34
47
|
end
|
data/lib/graphiti/version.rb
CHANGED