rooftop-algolia_search 0.1.0 → 0.1.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c8007e8a54464f67cf9b5abe73ff321a09a24cb6
|
|
4
|
+
data.tar.gz: 5eab0db249938cbd12f2686a5e58294afbfd26a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41b16207f2d628b91ca4ee5e94f87e1d88686bcaa29b8fc2c3fccca8e189306d0493de678b8489f295b0dbf76e91d390d85481bc44894c9cbc8cf50434fc8996
|
|
7
|
+
data.tar.gz: fdfd842bca4b5a207bbb769dbcdc3851cdaccb92ce28f3a5413d4ca9d526e9ae65c0e6c57a258cf9763bbc9e0721ea0d2f67fb1066dd43cce24c481bc520c401
|
|
@@ -2,7 +2,7 @@ module Rooftop
|
|
|
2
2
|
module AlgoliaSearch
|
|
3
3
|
module FacetHelper
|
|
4
4
|
|
|
5
|
-
def build_facet_query(hash)
|
|
5
|
+
def build_facet_query(hash,opts = {})
|
|
6
6
|
# takes a hash like this:
|
|
7
7
|
# {
|
|
8
8
|
# foo: ['bar', 'baz'],
|
|
@@ -10,15 +10,31 @@ module Rooftop
|
|
|
10
10
|
#
|
|
11
11
|
# }
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
if opts[:or]
|
|
14
|
+
# returns this
|
|
15
|
+
# ["foo:bar", "foo:baz", "qux:boo"]
|
|
16
|
+
result = []
|
|
17
|
+
hash.each do |k,v|
|
|
18
|
+
if v.is_a?(Array)
|
|
19
|
+
v.each {|val| result << "#{k}:#{val}"}
|
|
20
|
+
else
|
|
21
|
+
result << "#{k}:#{v}"
|
|
22
|
+
end
|
|
20
23
|
end
|
|
24
|
+
return [result]
|
|
25
|
+
else
|
|
26
|
+
# returns this
|
|
27
|
+
# [["foo:bar", "foo:baz"],"qux:boo"]
|
|
28
|
+
hash.collect do |k,v|
|
|
29
|
+
if v.is_a?(Array)
|
|
30
|
+
v.collect {|val| "#{k}:#{val}"}
|
|
31
|
+
else
|
|
32
|
+
"#{k}:#{v}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
21
36
|
end
|
|
37
|
+
|
|
22
38
|
end
|
|
23
39
|
end
|
|
24
40
|
end
|