active-record-data-tables 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "active-record-data-tables"
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kaspernj"]
12
- s.date = "2013-07-15"
12
+ s.date = "2013-08-29"
13
13
  s.description = "Helping functionality for filtering, sorting and stuff like that with data-tables and ActiveRecord."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -18,11 +18,11 @@ class ActiveRecordDataTables
18
18
  @executed = false
19
19
  end
20
20
 
21
- def execute
21
+ def execute(args = {})
22
22
  @executed = true
23
- @query = @model
23
+ @query = args[:search] || @model
24
24
 
25
- filter
25
+ filter unless args[:skip_filter]
26
26
  sorting
27
27
  limit
28
28
 
@@ -69,7 +69,10 @@ class ActiveRecordDataTables
69
69
  elsif match = key.to_s.match(/^(.+)_like$/) and @model.column_names.include?(match[1])
70
70
  next if val.blank?
71
71
  table = @model.arel_table
72
- @query = @query.where(table[match[1].to_sym].matches("%#{escape(val)}%"))
72
+
73
+ val.to_s.strip.split(/\s+/).each do |str|
74
+ @query = @query.where(table[match[1].to_sym].matches("%#{escape(str)}%"))
75
+ end
73
76
  elsif @args[:filter]
74
77
  ret = @args[:filter].call(:key => key, :val => val, :query => @query)
75
78
  @query = ret if ret
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: active-record-data-tables
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - kaspernj
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false
@@ -125,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  segments:
127
127
  - 0
128
- hash: 1815935002957672268
128
+ hash: 4040084657168273358
129
129
  version: '0'
130
130
  none: false
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement