json_api_toolbox 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89a9e4db48d90ab7b8bba2d5a2de49f2623af864
4
- data.tar.gz: dc5345b8754bf5bd588bedf55eb821d54a72c896
3
+ metadata.gz: bb8b7a1164443567101edd1115eaaa8c62365fb4
4
+ data.tar.gz: aa0f04f0cf16032453bb0d8584b931e5ae2ac182
5
5
  SHA512:
6
- metadata.gz: 90b780fa31005344f803eae599f449413a4b88820918af32b4a441de0a258bf851682d1937fbd0f5251cea749f2585895304a196be89f1426f243033f9d59e7a
7
- data.tar.gz: fa142ccb717180d303ef650f8f3854da74beb8a1f6b4374746e3072d33ec2f768fbdcee3ae6e9a0ad187e152286318d36ba7120a687a4ca1c9441e5bac5d181a
6
+ metadata.gz: 9cd40be8fa33c1459f051108e528cf940720320aaa924dc009d0e6f469da370a025bbae99deecb7c1622293e1abda43b494b9a3805fb7326b1bad299670145ff
7
+ data.tar.gz: 8d29e0e0d0a6f58bb1100ba3804f5ae73a650c84f63f4b71f2e736482c95b4bff7483912b8e772feea5020ed1051ea4406225944baa5e7a794daaebfe117c849
@@ -1,3 +1,3 @@
1
1
  module JsonApiToolbox
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/lib/postable.rb CHANGED
@@ -7,7 +7,8 @@ module JsonApiToolbox
7
7
  normalized_hash = hash.map do |key, value|
8
8
  child_model = self.association_class(model, key) if value.is_a? Hash
9
9
  key = associations.include?(key.to_sym) ? "#{key}_attributes" : key
10
- [key, value.is_a?(Hash) ? self.normalize_post(value, child_model) : value]
10
+ hash_value = check_child_association(value, key, model, child_model)
11
+ [key, hash_value]
11
12
  end
12
13
  Hash[normalized_hash]
13
14
  end
@@ -22,5 +23,13 @@ module JsonApiToolbox
22
23
  class_name = (association.options.symbolize_keys[:class_name] || key)
23
24
  ActiveSupport::Inflector.singularize(class_name).camelize.constantize
24
25
  end
26
+
27
+ def self.check_child_association(value, key, model, child_model)
28
+ if value.is_a?(Hash) && !model.has_attribute?(key)
29
+ self.normalize_post(value, child_model)
30
+ else
31
+ value
32
+ end
33
+ end
25
34
  end
26
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Bacha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-31 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport