hurray 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hurray.rb +6 -8
- 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: ab99a98864ed63a1e5521bb3d84a3afe0cf24402
|
4
|
+
data.tar.gz: bc639a89fd691bd14f1aea6ffe438a42c433a456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0689d961d4b314d7b007a50235f97fd80e87531bf895776fa6b2f318fa932ab827a26012dd66a72def9b1243107193a3f3ed9d2f0cc735c5fb5af6faad8746
|
7
|
+
data.tar.gz: caa65fbae448ad67ae42b4f71f91da36c6acde772059236ef626fbd01914de77bc3c26f82be3b639e153b72c001889ee5b53fefbd9e25bec4545f4a09e8d6316
|
data/lib/hurray.rb
CHANGED
@@ -15,11 +15,12 @@ module Hurray
|
|
15
15
|
# hash: (Hash)
|
16
16
|
|
17
17
|
def ordered_with(hash)
|
18
|
-
params =
|
18
|
+
params = []
|
19
|
+
parse_ordered_with_params(hash, params)
|
19
20
|
|
20
21
|
order_clause = ''
|
21
22
|
params.each_with_index do |param, index|
|
22
|
-
order_clause << '
|
23
|
+
order_clause << ', ' if index != 0
|
23
24
|
order_clause << "CASE #{param[:table]}.#{param[:column]} "
|
24
25
|
array = param[:array]
|
25
26
|
array.each_with_index do |el, pos|
|
@@ -33,18 +34,15 @@ module Hurray
|
|
33
34
|
|
34
35
|
private
|
35
36
|
|
36
|
-
def parse_ordered_with_params(table = table_name, hash)
|
37
|
-
results = []
|
37
|
+
def parse_ordered_with_params(table = table_name, hash, params)
|
38
38
|
hash.each do |k, v|
|
39
39
|
if v.is_a? Hash
|
40
|
-
parse_ordered_with_params(k.to_s, v)
|
40
|
+
parse_ordered_with_params(k.to_s, v, params)
|
41
41
|
else
|
42
|
-
|
42
|
+
params << { table: table, column: k.to_s, array: v }
|
43
43
|
end
|
44
44
|
end
|
45
|
-
results
|
46
45
|
end
|
47
|
-
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|