filterameter 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a523b898a73ce9f67d723e9dcbf1131748bf7d431c8cab11dc6faa00ac9409a
|
4
|
+
data.tar.gz: 428a21db90c7823118037fe7fd698dda522644a3cf47bcb1b5c3e0b0d8a7418e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82db4c9d6db4b7bf27815e97ff3479fe2e0afc85ec66ea69db6807ba2ff0a98b2b61fe82975b61164c22eed53b07e59678dcd0098912d89f02909a4276ba44f9
|
7
|
+
data.tar.gz: 53401b585ec11bc664c8268425720e890bbce6197606366059d46c9eb78fd72350217860fb2cf54f1c16fd055a2c88b3fe81789e4a45cf97c0d618b89be400ef
|
@@ -40,8 +40,8 @@ module Filterameter
|
|
40
40
|
@query_variable_name ||= model_class.model_name.plural
|
41
41
|
end
|
42
42
|
|
43
|
-
def build_query(filter_params)
|
44
|
-
valid_filters(filter_params).reduce(model_class.all) do |query, (name, value)|
|
43
|
+
def build_query(filter_params, starting_query)
|
44
|
+
valid_filters(filter_params).reduce(starting_query || model_class.all) do |query, (name, value)|
|
45
45
|
@filters[name].apply(query, value)
|
46
46
|
end
|
47
47
|
end
|
@@ -39,8 +39,12 @@ module Filterameter
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def build_filtered_query
|
42
|
-
|
43
|
-
|
42
|
+
var_name = "@#{self.class.controller_filters.query_variable_name}"
|
43
|
+
instance_variable_set(
|
44
|
+
var_name,
|
45
|
+
self.class.controller_filters.build_query(params.to_unsafe_h.fetch(:filter, {}),
|
46
|
+
instance_variable_get(var_name))
|
47
|
+
)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
data/lib/filterameter/version.rb
CHANGED