pack_api 1.0.4 → 1.0.5
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac4e447544be25898609198e72112c0da8840ff64e9efdb143d463eec2a34c80
|
|
4
|
+
data.tar.gz: 7576d9e011b764ca396623d7faec591b962c7d3bd407d2f360351e37bdd5efaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c17deb6c83f2e79c9d16ed89caec0aa4baa11476285444956ed653a98badb778283636c3d2361c01b3587e0b9d573b7f5e805e019f05243457cd44420c90df0
|
|
7
|
+
data.tar.gz: b23f8c03c9f2c3bf122102222e0a9380f4870679fa0b335ae8fcb2e8485cad5d6768f4b74120c6e8811e0222c131d868532db57c230ed75e6e8ed1903ec10750
|
|
@@ -68,6 +68,10 @@ module PackAPI::Mapping
|
|
|
68
68
|
collection_associations.include?(model_attribute)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
def accepts_nested_attributes_for?(association_name)
|
|
72
|
+
model_type.nested_attributes_options.key?(association_name)
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
def resource_associations
|
|
72
76
|
@resource_associations ||= model_type.reflect_on_all_associations
|
|
73
77
|
.reject(&:collection?)
|
|
@@ -81,7 +85,9 @@ module PackAPI::Mapping
|
|
|
81
85
|
end
|
|
82
86
|
|
|
83
87
|
def normalize_association_reference(api_attribute, model_attribute)
|
|
84
|
-
if
|
|
88
|
+
if accepts_nested_attributes_for?(model_attribute)
|
|
89
|
+
api_attribute
|
|
90
|
+
elsif resource_association?(model_attribute)
|
|
85
91
|
normalize_resource_association_reference(api_attribute)
|
|
86
92
|
elsif collection_association?(model_attribute)
|
|
87
93
|
normalize_collection_association_reference(api_attribute)
|
data/lib/pack_api/version.rb
CHANGED