graphiti 1.0.alpha.10 → 1.0.alpha.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d73c18bd56aa9ce3103c3e1be9d6aa53df14d246
4
- data.tar.gz: da7f2ff960fb4592610dfb6ea30a5ff981378bda
3
+ metadata.gz: 8b451b3a2214bfee53214b84b53455b40df0a555
4
+ data.tar.gz: f3208a80a842591303a7f091f6544edb1c26ac3b
5
5
  SHA512:
6
- metadata.gz: 69a8290f78ca0abcee5971e6ffec58c3884d9f81a44f5b2bb59967cfb18311cb9274ad3329689b31c338586347fa2089df0d82e136d1d74a91c2073d591062a3
7
- data.tar.gz: ac000566edc5afc1c05af3db4a179454a9766da798995b3c35fcdda9bc01bbff40d697b598c217b39619378a8052f56c7961e931c44ced3663361e9950409503
6
+ metadata.gz: 877bbfdfc4af3bd92c6ff59bc932d5dc1022a9fee8ed2d138da4045cd01c7c5249e2ef06c993e83084fce6c5fa89f7f54ae6a05ca778750d4eb95e7ff01ee887
7
+ data.tar.gz: 075a9538fd31ecc16c84a317d3d80445d447de5598eb4bd23afa493c482845789fe33b66af0b4c699c976e513e1f9bd721096d7b0b7018303d6b56fa1d9420a4
@@ -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
- inner = @serializer.attribute_blocks.delete(@name)
24
- wrapped = wrap_proc(inner)
25
- @serializer.send(_method, @name, serializer_options, &wrapped)
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
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.alpha.10"
2
+ VERSION = "1.0.alpha.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.alpha.10
4
+ version: 1.0.alpha.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond