kadmin 0.8.0 → 0.9.4

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
  SHA256:
3
- metadata.gz: d9951931ba6b660b218da8b52c56273e7892ae8028877a0a9dfd892b76cc7a34
4
- data.tar.gz: 86c58851ca2dc31823bdd0f371de9cc3785855581c6cff87d6c4cd1f7104debf
3
+ metadata.gz: fe93b6bebb3211e1154d0740928d46babcea9a5b8274d5143bc1d05045258582
4
+ data.tar.gz: ebc7620ec9474cd3f90d527847385b799293982d4a2744607d9b1ad1e7c5259e
5
5
  SHA512:
6
- metadata.gz: 45dcc66e5ad58f7c67dfbbc14bf3e83de99916eca5e7579ab38df855f7e40c8f0adec45c4c21562308bf4ab6e702e7286504288ed916b8dd747a86da5b75050c
7
- data.tar.gz: be94feb91612b7d396e248b96c0329d4c24e6bc4f6ffe15b635121dc4a680336900eed6dcd79bc7fb582677311e49ad4c86286e74f250c0d58e6676e2691cf77
6
+ metadata.gz: cdd30f1c442519fcd778cfa3a8068e80372e8ade3e7e11d5fa3ce43ed72e53743c2e8f895cb1b126a6d7dd1265ab1dd04a543a14e1671a89b3191370e91aaa26
7
+ data.tar.gz: 7d30719111ee40319e908c70d3f8204830babcc98c9a31989a4bed0b37c96e3d1ef8742488c41bb1ab3950007a1109f6cbf017f79ff955c216e5548289954587
@@ -37,18 +37,27 @@ module Kadmin
37
37
 
38
38
  private
39
39
 
40
- # DEPRECATED
41
- def resources_deprecated_parse_filter(hash)
42
- filter_scope = lambda do |scope, value|
43
- search_value = quote(fuzz(value))
44
- conditions = Array.wrap(hash[:column]).map do |column_name|
45
- %(#{scope.quoted_table_name}.`#{column_name}` LIKE #{search_value})
40
+ # Takes in a column or array of column names, and returns a proc
41
+ # ready to be used by this class.
42
+ # Columns can contain either symbols, strings, or directly an Arel::Node,
43
+ # allowing you to reference joined tables as well.
44
+ def resources_filter_matches(columns)
45
+ return lambda do |v|
46
+ pattern = "%#{v}%"
47
+ conditions = Array.wrap(columns).reduce(nil) do |acc, column|
48
+ column = arel_table[column] unless column.is_a?(Arel::Attributes::Attribute)
49
+ matcher = column.matches(pattern)
50
+ acc.nil? ? matcher : acc.or(matcher)
46
51
  end
47
52
 
48
- scope.where(conditions.join(' OR '))
53
+ where(conditions)
49
54
  end
55
+ end
50
56
 
51
- Finder::Filter.new(name: name, scope: filter_scope)
57
+ # DEPRECATED
58
+ def resources_deprecated_parse_filter(hash)
59
+ filter_scope = resources_filter_matches(hash[:column])
60
+ Finder::Filter.new(hash[:name], filter_scope)
52
61
  end
53
62
  end
54
63
  end
@@ -1,3 +1,3 @@
1
1
  module Kadmin
2
- VERSION = '0.8.0'.freeze
2
+ VERSION = '0.9.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Pepin-Perreault
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-04-03 00:00:00.000000000 Z
13
+ date: 2018-04-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails