faceted_search 3.0.1 → 3.0.2
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 +4 -4
- data/README.md +4 -1
- data/app/models/faceted_search/facets/tree.rb +15 -3
- data/lib/faceted_search/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 723f4aee4045acfda2a5de29d3278787b9aa9f8eb9af52ad4e44438374a880f4
|
4
|
+
data.tar.gz: f27bbdfb8ee732c12c761b251b1198a6f7f8b01036f462e7d3856f2c14b4b5cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32bcd675c7620682358f7d7d8decf72b25f4e488830651bd7d75bc6e46bc7c0e1fee0b1c9d2cc0b81138eba1896048ebef1db7673e7d8a9a3b9d64ee9b6fcdf1
|
7
|
+
data.tar.gz: 00e77168dbc238c594a866681e6b32275adb42caa7db3e695b5a3da29da527f12eb12f2f7599f9e59c817900ec0741fc533efb48439a4c9c0c46b1099f077447
|
data/README.md
CHANGED
@@ -1,23 +1,35 @@
|
|
1
1
|
module FacetedSearch
|
2
2
|
class Facets::Tree < Facets::DefaultList
|
3
3
|
|
4
|
+
def children_scope
|
5
|
+
@options[:children_scope] ||= Proc.new { |children| children }
|
6
|
+
end
|
7
|
+
|
4
8
|
def selected_objects
|
5
9
|
source.where(find_by => params_array)
|
6
10
|
end
|
7
11
|
|
8
12
|
def selected_object
|
9
|
-
|
13
|
+
source.find_by(find_by => params_array.last)
|
10
14
|
end
|
11
15
|
|
12
16
|
# All values, not filtered
|
13
17
|
# Otherwise, we would need to search all the children to do a good filtering
|
14
18
|
def values
|
15
|
-
root? ?
|
16
|
-
:
|
19
|
+
root? ? values_root
|
20
|
+
: values_children
|
17
21
|
end
|
18
22
|
|
19
23
|
protected
|
20
24
|
|
25
|
+
def values_root
|
26
|
+
source.root
|
27
|
+
end
|
28
|
+
|
29
|
+
def values_children
|
30
|
+
children_scope.call selected_object.children
|
31
|
+
end
|
32
|
+
|
21
33
|
def root?
|
22
34
|
params_array.empty?
|
23
35
|
end
|