hurray 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hurray.rb +6 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b793175c03a722e4ccefe615c0ed55eef56016db
4
- data.tar.gz: e8512e3b6696f47ed55eaf0bd66cf8c6a7ae290f
3
+ metadata.gz: ab99a98864ed63a1e5521bb3d84a3afe0cf24402
4
+ data.tar.gz: bc639a89fd691bd14f1aea6ffe438a42c433a456
5
5
  SHA512:
6
- metadata.gz: 1dfff74b4ddd096c24baf0aa379f23355463d2c7891dbd1f16ff25f04a2d580fbaf8de59f9980f210e83560cc234fb95f9c863acdfbfd638eb726ec1265036ad
7
- data.tar.gz: bbaa37b46f7ce1acb105a2685aae896a571f6fd78647a545bb87069833b87ecd534e7b04c6ab9cc020442dcf1dd9312273e34260ed3eec42c976c56a499ef733
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 = parse_ordered_with_params(hash)
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 << ' , ' if index != 0
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
- results << { table: table, column: k.to_s, array: v }
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hurray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Kotov