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: 97bc00d12d3a953cbedcfa92a1b8c469ef442936ebaac28157fd4a88cb8dc62c
4
- data.tar.gz: f7233773047377d725a047e3b01b159f097ecbece898b83d824b197e6146db61
3
+ metadata.gz: 6a523b898a73ce9f67d723e9dcbf1131748bf7d431c8cab11dc6faa00ac9409a
4
+ data.tar.gz: 428a21db90c7823118037fe7fd698dda522644a3cf47bcb1b5c3e0b0d8a7418e
5
5
  SHA512:
6
- metadata.gz: e19b7c776809225651165bf7714ca7820cb5c3824138ff798842d4b99cf67c58d92eb077070d9959874aa6ebf2352c2b5cf34f6c223241c64b36d4dc7b2ee59e
7
- data.tar.gz: d24c6b1abe68ef70cbb03c8abecda1147f1dc889b2b7cd90062c35245f1c442d07ff6562866cb4d097b0bc2e3572cc02c5c5a406a146f7af91fa85b3abc883c9
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
- instance_variable_set("@#{self.class.controller_filters.query_variable_name}",
43
- self.class.controller_filters.build_query(params.to_unsafe_h.fetch(:filter, {})))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Filterameter
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filterameter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Kummer