effective_datatables 3.0.15 → 3.0.16

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
  SHA1:
3
- metadata.gz: e0a7e266b00b4bc168dbf066d2be5a0b5a3d00a8
4
- data.tar.gz: b5b54094cdf557a848a0466c27bdb4efce57d210
3
+ metadata.gz: a36c56e15a3e3c9d57862183dc41ed61dfa7be69
4
+ data.tar.gz: 38ada5d0f882aabd61510b21d2153bd0708ee437
5
5
  SHA512:
6
- metadata.gz: 680dc369209e29efcdbce860039d2f6f9108c033f182cdcead1e3834df7cd50a6a105f548132decac8049bb16e229a08269f1089814455f04d13d49d9d9f9b90
7
- data.tar.gz: baeb9a1a4428b1acf8eb6493fe7e63a54a4c71316177adead6b9513ac78f900c692b4808b617ba0caa89a925e226e41b0df3045091493208918fce17a78075c6
6
+ metadata.gz: 6d0cfc1d01e242b7b5afe8b74b6c27d1cafc24fcf8bec8f1de0e13295ca9ae3f005e5dd9a5cb5c2d04f8d96ba9b8fc01b34592662dc74a46317a489f1cd59d61
7
+ data.tar.gz: 3379dbd9030d211d3f21d72a7c8db65ffb5746e506a6d9497b5d6b30eda3b78408ba00c546c17a4e3679929c9a7d7efc385a69c6cffb2fcee955263795472185
@@ -73,7 +73,7 @@ module Effective
73
73
 
74
74
  fuzzy = column[:search][:fuzzy]
75
75
  term = Effective::Attribute.new(column[:as]).parse(value, name: column[:name])
76
- term_downcased = term.downcase if fuzzy && term.kind_of?(String)
76
+ term_downcased = term.to_s.downcase
77
77
  macros = Effective::Resource.new('').macros
78
78
 
79
79
  if term == 'nil'
@@ -104,21 +104,21 @@ module Effective
104
104
  row[index] == term
105
105
  end
106
106
  when *macros, :resource
107
- Array(row[index]).any? do |resource|
108
- if column[:as] != :resource
109
- resource = resource.send(column[:name])
110
- end
107
+ resources = Array(column[:as] == :resource ? row[index] : row[index].send(column[:name]))
108
+ terms = Array(term)
111
109
 
112
- matched = false
110
+ resources.any? do |resource|
111
+ terms.any? do |term|
112
+ matched = false
113
113
 
114
- if term.kind_of?(Integer) && resource.respond_to?(:id)
115
- matched ||= (resource.id == term || resource.to_param == term)
116
- elsif term.kind_of?(Array) && resource.respond_to?(:id)
117
- matched ||= term.any? { |term| resource.id == term || resource.to_param == term || resource.to_param == value }
118
- end
114
+ if term.kind_of?(Integer) && resource.respond_to?(:to_param)
115
+ matched = (resource.id == term || resource.to_param == term)
116
+ end
119
117
 
120
- matched ||= (fuzzy ? resource.to_s.downcase.include?(term_downcased) : resource.to_s == term)
118
+ matched ||= (fuzzy ? resource.to_s.downcase.include?(term.to_s.downcase) : resource.to_s == term)
119
+ end
121
120
  end
121
+
122
122
  else # :string, :text, :email
123
123
  if fuzzy
124
124
  row[index].to_s.downcase.include?(term_downcased)
@@ -19,7 +19,7 @@ module Effective
19
19
  if active_record_collection?
20
20
  columns.each do |name, opts|
21
21
  opts[:as] ||= resource.sql_type(name)
22
- opts[:sql_column] = (resource.sql_column(name) || false) if opts[:sql_column].nil?
22
+ opts[:sql_column] = resource.sql_column(name) if opts[:sql_column].nil?
23
23
 
24
24
  case opts[:as]
25
25
  when *resource.macros
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.0.15'.freeze
2
+ VERSION = '3.0.16'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.15
4
+ version: 3.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-06 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails