standardapi 1.0.21 → 1.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/standard_api/includes.rb +9 -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: 0c235c68ca069d23f7a7bab6cacf6c3c0437731d
|
4
|
+
data.tar.gz: ee26ab2fc982ac69b49089d7d11145e4a06a0d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a87e9d682ef1c5b5c5881bd959fff6ee97ae76832e9ca2d04bd73e1455b28a2aebaa52db10b2485da1360209c2a0bba7ad9ff5c23daf7548018c5a3a97dd730
|
7
|
+
data.tar.gz: 8088daf1b652f27db181021b391e5b2457a67e2a69c354321947296cffb5984abcb766f759026befed6be50238053c9eb9aabe1992cd72fcbb3513ed14215f24
|
@@ -7,6 +7,8 @@ module StandardAPI
|
|
7
7
|
# { x: true, y: true } => { x: {}, y: {} }
|
8
8
|
# { x: { y: true } } => { x: { y: {} } }
|
9
9
|
# { x: [:y] } => { x: { y: {} } }
|
10
|
+
# { x: { where: { y: false } } } => { x: { where: { y: false } } }
|
11
|
+
# { x: { order: { y: :asc } } } => { x: { order: { y: :asc } } }
|
10
12
|
def self.normalize(includes)
|
11
13
|
normalized = ActiveSupport::HashWithIndifferentAccess.new
|
12
14
|
|
@@ -14,7 +16,13 @@ module StandardAPI
|
|
14
16
|
when Array
|
15
17
|
includes.flatten.compact.each { |v| normalized.merge!(normalize(v)) }
|
16
18
|
when Hash
|
17
|
-
includes.each_pair
|
19
|
+
includes.each_pair do |k, v|
|
20
|
+
if ['where', 'order'].include?(k.to_s) # Where and order are not normalized
|
21
|
+
normalized[k] = v
|
22
|
+
else
|
23
|
+
normalized[k] = normalize(v)
|
24
|
+
end
|
25
|
+
end
|
18
26
|
when nil
|
19
27
|
{}
|
20
28
|
else
|