like_search 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/like_search/version.rb +1 -1
- data/lib/like_search.rb +4 -2
- metadata +1 -1
data/lib/like_search/version.rb
CHANGED
data/lib/like_search.rb
CHANGED
@@ -8,6 +8,8 @@ module LikeSearch
|
|
8
8
|
}
|
9
9
|
DB.default = "{field} like ?"
|
10
10
|
|
11
|
+
|
12
|
+
|
11
13
|
extend ActiveSupport::Concern
|
12
14
|
|
13
15
|
module ClassMethods
|
@@ -28,9 +30,9 @@ module LikeSearch
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
def token_search(query)
|
33
|
+
def token_search(query, token_size=2)
|
32
34
|
query.to_s.split.inject(scoped) do |current_scope, term|
|
33
|
-
term.size >
|
35
|
+
term.size > token_size ? current_scope.search(term) : current_scope
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|